Reputation: 5956
As part of a CD build, I want to take a pre-release artifact published to a nuget feed and update it in our main project. However, I can't figure out how to update the package on the command line. The following commands generate the following errors:
Command
nuget update $PROJECT -Id $PACKAGE_ID
Error:
MSBuild auto-detection: using msbuild version '15.0' from '/Library/Frameworks/Mono.framework/Versions/5.18.1/lib/mono/msbuild/15.0/bin'. Unable to update. The project does not contain a packages.config file.
Command:
dotnet add $PROJECT package $PACKAGE_ID
Error:
/Users/jeffward/Projects/(957,3): error MSB4019: The imported project "/usr/local/share/dotnet/sdk/2.1.700/Xamarin/iOS/Xamarin.iOS.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. Unable to create dependency graph file for project ''. Cannot add package reference.
Is there any way to do this on the command line?
Upvotes: 0
Views: 694
Reputation: 47907
From the error messages it looks like you are using PackageReferences.
For stable NuGet package versions you should be able to do this with a PackageReference wildcard.
<PackageReference Include="Newtonsoft.Json" Version="*" />
From the command line:
msbuild /r
Which should restore the latest Newtonsoft.Json version.
You may need to use 'msbuild /r /p:RestoreForce=true' if there is an existing obj/project.assets.json file to force the restore to re-run.
For pre-release versions you will need to include part of the version which indicates to NuGet that you want pre-releases.
<PackageReference Include="Microsoft.CSharp" Version="4.6.0-*" />
The above will restore the latest pre-release version, currently 4.6.0-preview6.19303.8.
Upvotes: 2