Use the relative solution packages folder with NuGet and project.json

I have a solution with a folder packageschecked in the source control. I changed some projects to use the file project.json, and not packages.configto define dependencies. Projects are ordinary projects .csproj, not DNX projects .xproj. Everything seemed to work correctly, however after updating the package I noticed that the new version was not added to the solution folder packages. Instead, it has been added to the new NuGet shared packages folder in the user profile folder.

So the question is, how can I get NuGet to use a folder packages, not a shared folder?

Approaches I have tried so far without success:

  • Adding a file global.jsonto the solution folder indicating"packages": "packages"
  • Setting <add key="disableSourceControlIntegration" value="false" />in.nuget\nuget.config
+4
source share
1 answer

NuGet 3.2 added support for specifying a shared global package folder using an environment variable NUGET_PACKAGES. You can set the full path to the alternative global package folder, however, I found that if you just set the variable to “packages”, then NuGet tools in Visual Studio will treat it as a relative path in the folder with your solution. This allowed me to install and restore NuGet packages using the folder packages.

, Microsoft.NuGet.targets, NuGet. NugetPackagesDirectory msbuild, , . , C:\Program Files (x86)\MSBuild\Microsoft\NuGet\Microsoft.NuGet.props:

<PropertyGroup Condition="'$(NugetPackagesDirectory)' == ''">
  <NugetPackagesDirectory>$(SolutionDir)packages</NugetPackagesDirectory>
</PropertyGroup>

, props , . .

, , , packages\<package_name>\<version>\ packages\<package_name>.<version>\, . , .

, -, . - NuGet project.json, packages.config .

+2

Source: https://habr.com/ru/post/1628064/


All Articles