简体   繁体   中英

Where are the libraries from the nuget reference stored on the disk?

I am developing a universal windows application. I see that in the reference section i have Microsoft.NETCore.UniversalWindowsPlatform with a blue NuGet icon. When i double click on it, the object explorer does not appear as in normal library references.

As i read the documentation i understand that NuGet does download a copy of the library, however i cannot locate the DLL anywhere, i looked in all the folders.

Where can i find the DLL for the NuGet Reference and what advantage does this new implementation bring? Cause i can't see any gains especially if you are offline and you cant peek in using the object explorer.

在此输入图像描述

It is not a DLL. Documentation is hard to come by and it is likely to change rapidly. But you can get a cue from using a text editor to look at the Microsoft.NETCore.UniversalWindowsPlatform.nuspec file in C:\\Users\\yourname\\ .nuget\\packages\\Microsoft.NETCore.UniversalWindowsPlatform\\5.0.0

You'll see it is actually an XML file that contains a laundry list:

<dependencies>
  <dependency id="Microsoft.NETCore.Runtime" version="1.0.0" />
  <dependency id="Microsoft.NETCore" version="5.0.0" />
  ... etc

Those are in turn Nuget packages that are needed to get your project built. The first one in the list is located here .

These packages are retrieved when you first build your project. They are stored in C:\\Users\\yourname\\ .nuget\\packages as well. The first one on the list, Microsoft.NETCore.Runtime has yet another redirection in its runtime.json file:

  "runtimes": {
    "win7-x86": {
      "Microsoft.NETCore.Runtime": {
        "Microsoft.NETCore.Runtime.CoreCLR-x86": "1.0.0",
        "Microsoft.NETCore.Windows.ApiSets-x86": "1.0.0"
      }
    },
    ...etc

Note the "win7" moniker, there ought to be a story in there somewhere :) The Microsoft.NETCore.Runtime.CoreCLR-x86 and Microsoft.NETCore.Windows.ApiSets-x86 are yet more nuget packages. Note that there are entries for every possible target, it isn't very "universal" when you get down to the details.

Microsoft.NETCore.Runtime.CoreCLR-x86.nuspec contains yet another laundry list:

<dependencies>
  <dependency id="System.Collections" version="[4.0.10]" />
  <dependency id="System.Diagnostics.Debug" version="[4.0.10]" />
  ...etc

We're finally getting to the real DLLs. System.Collections is a Nuget package that the compiler actually sees with the /reference option. Its ref\\dotnet subdirectory has the reference assembly, its lib\\netcore50 subdirectory has the runtime assembly.

Note how there are a very large number of DLLs involved. The .NET Framework of old is split-up into many sub-assemblies. .NET Native is pretty essential to prevent that from killing cold start time. It compiles all of these assemblies, using only the methods that you actually use, and merges them back into a blob.

Very convoluted, there has to be a machine somewhere that knows how to keep all these balls in the air. Rather scary too, you'd have to wonder if this contraption is still going to work 10 years from now.

UPDATE: and it didn't, lots of changes since I first wrote this post. .NETCore version 5 was renumbered to version 1.0 Version 2.0 just shipped. The team acknowledged that having so many assemblies was only a temporary solution to make it easier to makes changes. I suspect that this only truly starts stabilizing at the proverbial version 3.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM