Restore using nuget.exe based on a msBuild Condition #11452
-
I got a project with multiple SDKs and due to different build solutions, this project gets compiled on different agents. Some with older Visual Studio versions, not supporting NET6 yet.
Before the build starts, I try to restore the packages using
Depending on the build solution, I either use the first or second msbuild call:
As the older Visual Studio does not support .NET6, I fails. So, I am missing an switch to set such a variable and allow to restore the solution using the argument switch. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Instead of using nuget.exe to restore, you can use msbuild: https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#restore-target
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: 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. |
Beta Was this translation helpful? Give feedback.
-
@zivkan
|
Beta Was this translation helpful? Give feedback.
Instead of using nuget.exe to restore, you can use msbuild: https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#restore-target
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.