问题
I've added Autofac
library using NuGet
and I see it in my references as shown below.
But when I check the properties [F4] of Autofac by clicking on it, it shows empty property box in Visual Studio.
Also, I don't see Autofac
folder under packages
folder.
I see only Package reference in .csproj
file. Then how does it locates the DLL? Where is the actual DLL? I see it's automatically coming inside BIN. How does it come?
Main Issue: Locally I'm able to build the solution but same solution fails on TFS build agents. It's unable to find the NuGet reference. So where can I find DLL references? or how to push it to TFS?
回答1:
Assume you are using TFS 2015, the NuGet Restore task name should be NuGet Installer
which under Package
when you add tasks.
So, if you have installed Nuget in the build machine, then you can use the task directly.
You can also custom nuget.exe
for TFS 2015 build -- Just specify the Path to NuGet.exe
You can refer to Mummy's blog- Custom nuget.exe for TFS 2015 build for details.
回答2:
You use the new Package Reference where the NuGet files get get stored into a cache:
Solution-local packages folders are no longer used – Packages are now resolved against the user’s cache at
%userdata%\.nuget
, rather than a solution specific packages folder. This makes PackageReference perform faster and consume less disk space by using a shared folder of packages on your workstation.
回答3:
Add a NuGet Restore
task to your build so that the packages are restored.
回答4:
As @magicandre1981 already explained, with PackageReference
style package referencing (as apposed to package.config
-style, also see this for more background on the differences, in case you didn't know), the packages are not located in a per-solution packages-folder, but in a central one (by default %USERPROFILE%\.nuget\packages
). Albeit you can easily change the location using the NUGET_PACKAGES
environment variable (which also works as a TFS Build variable, because they are provided as environment variables to build steps).
Furthermore, inside Visual Studio you see no path, because the actual path to the DLL is determined at build time. You can see part of that path in your <project-dir>\obj\project.assets.json
file (which is generated during the restore
target/operation), but the full path you will only see in the MSBuild logs (for example when actually calling the csc.exe
executable/C# compiler or during ResolveAssembyReferences
-task).
Note that for .NET Core, i.e. "SDK style" projects, the path is actually shown in properties (as are the actual DLLs in a node underneath the "package" node.
One can only assume that the integration of PackageReference in "old" projects is not fully done yet (if ever).
For comparison a PackageReference in an "old" / non-SDK-style project:
来源:https://stackoverflow.com/questions/50815222/where-does-visual-studio-is-referring-the-actual-nuget-referenced-dll