1
votes

Just noticed that UWP applications do not contain most of assemblies they reference. Instead they require nuget manager on installation and as I understand somehow install required dependencies directly into GAC. I just called Install-Package and faced the prompt to install nuget.

So in my app I have win32 appservice which is called as trusted app from uwp. It has dependency on Newtonsoft.Json. But win32 application crashes with error that assembly can't be located. Of course it can't be located as it's not in the application folder. But how it should work? Why it's not located in GAC? The only place where this assembly exists is C:\Windows\WinSxS\msil_hyperv-ux-ui-newtonsoftjson_31bf3856ad364e35_10.0.17134.1_none_2490c36295ddbc03 which is GAC storage. But it's still not resolved. So how it should work?

UPD: Here is the sample code to reproduce the problem: github.com/GDreyV/uwp-assemblies-test To reproduce it you need to switch to Release configuration, right click on Uwp project and choose Store - Create App Packages. After package is ready just install it and run.

1
NuGet packages do not get installed to the GAC. They are installed locally to the project. I recommend the documentation: docs.microsoft.com/en-us/nuget/consume-packages/…Devin Goble
Yeah, I see the point. But it seems to work differently with UWP packages. It was just my guess about the flow with UWP as I didn't find any documentation how it really works. I know that packages require nuget and that libraries are not in the folder of the app. So I don't follow how and where nuget install packages and how are they resolved?Andrew
It's not different using UWP. You may be confusing older projects with how PackageReference works. You shouldn't need to know where NuGet-installed assemblies are located. Referencing them explicitly isn't the correct approach. docs.microsoft.com/en-us/nuget/consume-packages/… and blog.nuget.org/20170316/…Devin Goble
I'm not referencing them explicitly. The problem is that appservice (which is win32 executable) which is distributed with uwp app uses the same references and can't locate them as they do not exist in the application folder.Andrew
UWP applications are AOT (via .NET Native) while packaging, msdn.microsoft.com/en-us/magazine/mt590967.aspx So you cannot rely on the dependencies from the UWP project. You might try to use ILMerge or IL Repack to bundle the dependencies of your console app together. BTW, don't use the term "Win32", as it usually means VB6 or VC++ projects.Lex Li

1 Answers

1
votes

As Lex Li pointed out UWP uses .NET Native which includes ahead-of-time (AOT) compilation process. It means:

All dependencies on the .NET runtime are removed, so your end users will never need to break out of their setup experience to acquire the specific version of the .NET Framework your app references. In fact, all the .NET dependencies are packaged within your application, so the behavior of your app shouldn’t change just because there’s a change in the .NET Framework installed on the machine.