Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild Macro for NuGet package directory

I'm working on a NuGet package that adds a step to the build process by using a .targets file.

I need to reference other files from my NuGet package in order to complete the build successfully.

In the past, I've used $(SolutionDir)packages\MyPackage and all has worked fine.

However, I was just playing around with the VS 2017 RC, and I noticed that my package was installed in the global NuGet package directory, not in the solution folder.

Is there some macro that I can use from MSBuild, that contains the path for the NuGet packages folder? It is a requirement that I maintain compatibility with VS2012.

like image 569
Adam Schiavone Avatar asked Feb 16 '17 15:02

Adam Schiavone


People also ask

Does MSBuild restore NuGet packages?

msbuild -t:Restore will restore nuget packages for projects with PackageReference nuget management format.

What directory is the package installed with NuGet?

The global-packages folder is where NuGet installs any downloaded package.

Where is .NuGet folder located?

The location of the default global packages folder. The default is %userprofile%\. nuget\packages (Windows) or ~/. nuget/packages (Mac/Linux).


1 Answers

The $(NuGetPackageRoot) macro points to the package root.

like image 60
yoel halb Avatar answered Oct 14 '22 21:10

yoel halb