MSBuild 15 NuGet还原和构建 [英] MSBuild 15 NuGet restore and build

查看:565
本文介绍了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还原有关的文件,即没有bin \ Release \文件夹.

MSBuild "succeeds" but just creates an obj folder with some files relating to the NuGet restore i.e. no bin\Release\ folder.

为了恢复构建,我必须在上面发出两个命令(显然首先要恢复).

In order to restore and build I have to issue both commands above (restore first, obviously).

我已经升级了所有package.config文件,以使用.csproj文件中的最新PackageReference.

I have upgrade all of the packages.config files to use the latest PackageReference in the .csproj file.

是否可以使用单个命令来还原和构建?

Is there a way to both restore and build using a single command?

推荐答案

MSBuild 15.5将引入 a /restore标志实现了此功能.

MSBuild 15.5 will introduce a /restore flag that implements this functionality.

在此之前,理论上可以在同一调用(/t:Restore;Build)中运行还原和构建,但是不安全是不安全的,因为MSBuild可能会缓存项目文件而看不到由aBuild所做的更改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还原和构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆