Firstly, I think it would be useful for Travis to pre-install
NuGet.CommandLine , available from nuget or choco. Or if it is already installed, add it to the PATH. Doing so will mean people dont need to do the following OneGet set up in order to sanely use NuGet directly.
But for people who do want to use OneGet, or NuGet directly, here is the setup as it isnt immediately obvious.
- powershell -c "Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine" - powershell -c "Import-Module PackageManagement; Install-PackageProvider Nuget" - powershell -c "Import-Module PackageManagement; Register-PackageSource -Name NuGetOrg -Location https://www.nuget.org/api/v2 -ProviderName NuGet" - powershell -c "Import-Module PackageManagement; Install-Package -Source NuGetOrg -Name NuGet.CommandLine -Force -ExcludeVersion -Destination C:\tools"
-Force, it will hang for 10mins.
NuGetOrg can be whatever name you want. No doubt, some of the above isnt optimal.
Ready to roll
- /c/tools/NuGet.CommandLine/tools/nuget sources list Registered Sources: 1. NuGetOrg [Enabled] https://www.nuget.org/api/v2 2. Microsoft Visual Studio Offline Packages [Enabled] C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Why would I want to do that instead of
choco install nuget.commandline ? Firstly it is a bit silly to be using choco if I actually want to be using nuget, and nuget will re-install the same packages as choco doesnt register them in the same locations out of the box. And I found this to be a significant difference with AppVeyor, which has nuget CLI in the PATH by default, and I’d like to keep my Travis and AppVeyor configs very similar. But more importantly, choco infrastructure isnt as reliable as NuGet.org and other OneGet providers, so I want to be getting a basic environment set up before using choco, so I can handle failures more sanely.
Also, if some of the above OneGet preparation commands are done prior to VM launching, using NuGet is much faster than using choco.