MSBuild 15 NuGet 还原和构建

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
quot;Overflowquot; compiler error with -9223372036854775808L(编译器错误-9223372036854775808L(Q;溢出Q))
Visual Studio 2010 ReportViewer Assembly References(Visual Studio 2010 ReportViewer程序集引用)
Weird behaviour when I open a reportviewer in WPF(在WPF中打开报表查看器时出现奇怪的行为)
how do i pass parameters to aspnet reportviewer(如何将参数传递给aspnet report查看器)