MSBuild 15 NuGet restore and build(MSBuild 15 NuGet 还原和构建)
问题描述
我正在尝试让新的 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 还原和构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MSBuild 15 NuGet 还原和构建


基础教程推荐
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01