问题
Sorry if this question has been answered before, but I just cannot seem to find an answer:
Is it possible to restore packages during the build using MSBuild only if projects are still using packages.config?
回答1:
As far as I can read on https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore it is possible:
MSBuild: use the msbuild /t:restore command, which restores packages packages listed in the project file (PackageReference only). Available only in NuGet 4.x+ and MSBuild 15.1+, which are included with Visual Studio 2017.
nuget restore
anddotnet restore
both use this command for applicable projects.
回答2:
According to documentation[1]:
The
restore
target works only for projects using the PackageReference format. It does not work for projects using thepackages.config
format; use nuget restore instead.
So you will have to use nuget.exe
restore instead. Look my other answer for that.
[1] https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets
来源:https://stackoverflow.com/questions/48956184/msbuild-and-package-restore-with-packages-config