Deny NuGet recovery package only in debug builds

I turned on the “Restore package” option in my solution, so when I upload the code to the CI server, it updates all the packages that it needs to build correctly, and it works fine. Now the problem is that on my local machine, assembly takes a lot of time because it is a “package update”. Is there a way to enable the recovery package only in the release build?

I tried moving the <RestorePackage> property in the .csproj files to the release / debug sections using false and true , but NuGet updates the attribute when opening the NuGet console and resets both values ​​to true ; also tried to include only the property in the release section, but then NuGet adds it to the global section ... so I was not lucky that it stayed the way I want ...

Any tips?

+7
source share
1 answer

You probably managed to answer this question, but if not, then these are the steps you need to follow

To the right, where your solution file is located inside Windows, there should be a folder named .nuget. Rename or delete this folder.

Now open each .csproj or .vbproj file in notepad or in any text editor and delete these lines

 <RestorePackages>true</RestorePackages> <Import Project="$(SolutionDir)\.nuget\NuGet.targets" /> 

The important part is deleting / renaming the .nuget folder. This should now completely disable package recovery.

Edit: To selectively disable package recovery for the DEBUG assembly, edit the Nuget.settings.targets file and change the following line

 <RestorePackages Condition="$(RestorePackages) == ''">false</RestorePackages> 

For

 <RestorePackages Condition="$(RestorePackages) == '' AND '$(Configuration)' == 'Debug'">false</RestorePackages> 

The Nuget.settings.targets file is located in the .nuget folder, which should be in the same folder as the solution file.

+15
source

All Articles