Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild and package restore with packages.config

Is it possible to restore packages during the build using MSBuild only if projects are still using packages.config?

like image 744
Alex I Avatar asked Feb 23 '18 21:02

Alex I


People also ask

How do I restore packages from package config?

config file. You can restore packages manually with nuget restore , dotnet restore , msbuild -t:restore , or through Visual Studio. The dotnet build and dotnet run commands automatically restore packages, and you can configure Visual Studio to restore packages automatically when it builds a project.

Does Msbuild restore NuGet packages?

msbuild -t:Restore will restore nuget packages for projects with PackageReference nuget management format. And your situation looks like packages. config nuget management format which you have used it.

What is the use of packages config?

The packages. config file is used in some project types to maintain the list of packages referenced by the project. This allows NuGet to easily restore the project's dependencies when the project is to be transported to a different machine, such as a build server, without all those packages.

How do I force a NuGet package to restore?

Restore NuGet packagesNavigate to Tools > Options > NuGet Package Manager > General, and then select the Allow NuGet to download missing packages check box under Package Restore. Enabling Restore NuGet Packages. In Solution Explorer, right-click the solution, and then select Restore NuGet Packages.


1 Answers

https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#restore-target

MSBuild 16.5+ also has opt-in support for the packages.config format.

Use:

msbuild -p:RestorePackagesConfig=true -t:restore
msbuild -t:build
like image 164
irvnriir Avatar answered Sep 19 '22 06:09

irvnriir