I enabled 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 great. Now the problem is that on my local machine, the build takes a long time to start because is "updating the packages". Is there a way to enable the Restore Package in release build only?
I've tried to move the <RestorePackage>
property in the .csproj files to the release/debug sections with false
and true
, but NuGet updates the attribute when a open the NuGet console and resets both to true
; also tried to only include the property in the release section, but then NuGet adds it to the global section... so I had no luck making it stay the way I want it...
Any advice?
You have probably managed to answer this by now but if not then these are the steps you need to follow
Right where your solution file is within Windows there should be a folder named .nuget. Either rename or delete this folder.
Now open each .csproj or .vbproj file in notepad or any text editor and remove these lines
<RestorePackages>true</RestorePackages>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" />
The important part is removing/renaming the .nuget folder. This should now disable package restore completely.
Edit: To selectively disable package restore for DEBUG builds edit the Nuget.settings.targets file and modify the following line
<RestorePackages Condition="$(RestorePackages) == ''">false</RestorePackages>
To
<RestorePackages Condition="$(RestorePackages) == '' AND '$(Configuration)' == 'Debug'">false</RestorePackages>
The Nuget.settings.targets file is under the .nuget folder which should be in the same folder as your solution file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With