Skip to content

Restore using nuget.exe based on a msBuild Condition #11452

Answered by zivkan
StarWars999123 asked this question in Q&A
Discussion options

You must be logged in to vote

Instead of using nuget.exe to restore, you can use msbuild: https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#restore-target

msbuild -t:restore my.sln

If you need to set properties on the command line, you already know how to do that with msbuild. If all the projects in the solution are SDK style, you probably don't need MSBuild and can use the dotnet CLI instead: dotnet restore my.sln.

For CI agents, have you considered the dotnet-install scripts: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script

Many Microsoft repos use it in their CI builds, including most, if not all of, github.com/dotnet, and NuGet.Client does as well.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by StarWars999123
Comment options

You must be logged in to vote
1 reply
@zivkan
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants