Is it possible to restore packages during the build using MSBuild only if projects are still using packages.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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With