MSBuild and package restore with packages.config

牧云@^-^@ 提交于 2019-12-13 12:14:09

问题


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 and dotnet 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 the packages.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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!