问题描述
我正在尝试让新的 MSBuild NuGet 恢复功能正常工作,但遇到了一个奇怪的问题.
I'm trying to get the new MSBuild NuGet restore feature to work and having an odd problem.
如果我这样做:
msbuild.exe mySolution.sln /p:Configuration=Release
我收到有关缺少软件包的错误消息.这是预期的行为.但是,如果我这样做:
I get an error about missing packages. This is expected behaviour. However, if I do:
msbuild.exe mySolution.sln /p:Configuration=Release /t:restore
MSBuild 成功",但只是创建了一个 obj 文件夹,其中包含一些与 NuGet 还原相关的文件,即没有 binRelease 文件夹.
MSBuild "succeeds" but just creates an obj folder with some files relating to the NuGet restore i.e. no binRelease folder.
为了恢复和构建,我必须发出上述两个命令(显然,首先恢复).
In order to restore and build I have to issue both commands above (restore first, obviously).
我已升级所有 packages.config 文件以使用 .csproj 文件中的最新 PackageReference.
I have upgrade all of the packages.config files to use the latest PackageReference in the .csproj file.
有没有一种方法可以使用单个命令同时恢复和构建?
推荐答案
MSBuild 15.5 将引入 a <实现此功能的代码>/恢复标志.
MSBuild 15.5 will introduce a /restore
flag that implements this functionality.
在此之前,理论上可以在同一调用 (/t:Restore;Build
) 中同时运行恢复和构建,但它是不安全的,因为 MSBuild 可能缓存项目文件,但看不到 NuGet 还原所做的更改./restore
选项将在恢复正常构建之前清除所有受影响的缓存.
Before that, it is theoretically possible to run both a restore and build in the same invocation (/t:Restore;Build
) but it is unsafe as MSBuild may cache project files and not see changes made by a NuGet restore. The /restore
option will clear all the affected caches before resuming with the normal build.
这篇关于MSBuild 15 NuGet 还原和构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!