I have set up NuGet Package Restore on my solution and it works nicely on my local machine. I followed the instructions supplied here:
http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages
The problem I have is on my build server where the following error occurs:
Package restore is disabled by default. To give consent, open the Visual Studio Options dialog, click on Package Manager node and check 'Allow NuGet to download missing packages during build.' You can also give consent by setting the environment variable 'EnableNuGetPackageRestore' to 'true'.
Unfortunately I dont have access to the build server as it is controlled off site so cant update the environment variable. Is there any other way around this? Anything I can add to the solution file or similar that would allow the package restore?
Try this package:
Install-Package NuGetEnablePackageRestore
NuGet can use local settings for it's behavior which can be unpredictable if you're not 100% sure how the server is configured.
I prefer putting the NuGet settings inside the <sln root>/.nuget/NuGet.targets
file which is version controlled and at a single location. I got this working with 3 quick edits to <sln root>/.nuget/NuGet.targets
, they should look as below after editting:
Change 1:
<!-- Enable the restore command to run before builds --> <RestorePackages Condition=" '$(RestorePackages)' == '' ">true</RestorePackages>
Change 2:
<!-- Determines if package restore consent is required to restore packages --> <RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">false</RequireRestoreConsent>
My comment: Awkward logic but think of "requires consent not equal to false must be true" (original) as "requires consent equal to true must be true" (translated) and it makes sense to change the last part to "false" (the edit)
Change 3 : I also added/uncommented the <PackageSource ... >
tag to to remove any dependencies on the
<ItemGroup Condition=" '$(PackageSources)' == '' "> <PackageSource Include="https://nuget.org/api/v2/" /> </ItemGroup>
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