VSTS 构建中的混合目标

Mixed targets in VSTS build

我们有一个 aspnet-core 应用程序,它由几个 .net standard 库、两个 aspnet-core mvc 应用程序和一个 .net framework 控制台应用程序组成。

这些都成功构建,在 Visual Studio 的解决方案中,以及单独使用 msbuild/dotnet build 命令。

我们现在正在尝试使用 VSTS 实现连续 integration/build。

我们发现 aspnet-core 网络应用程序构建成功,但 .net framework 控制台应用程序失败并出现如下多条错误消息:

2017-12-24T07:20:26.4090447Z C:\Program 
Files\dotnet\sdk.0.3\Microsoft.Common.CurrentVersion.targets(1988,5): 
warning MSB3245: Could not resolve this reference. Could not locate the 
assembly "Xxx.Core, Version=1.1.0.0, Culture=neutral, 
processorArchitecture=MSIL". Check to make sure the assembly exists on disk. 
If this reference is required by your code, you may get compilation errors. 
[d:\a\s\WinApps\ListBuilder\ListBuilder.csproj]
C:\Program Files\dotnet\sdk.0.3\Microsoft.Common.CurrentVersion.targets(1988,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.EntityFrameworkCore, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [d:\a\s\WinApps\TelemListBuilder\TelemListBuilder.csproj]

控制台应用程序遵循与 Web 应用程序相同的文件夹结构,但似乎无法找到任何引用的包。

我们的代理队列是 Hosted VS2017

我们有两个 VSTS 任务:RestoreBuild 来自 asp.net core 构建模板。

如有必要,如果我们可以从构建中排除控制台应用程序,我们将很高兴。

由于有通用的.net framework项目和.net core项目,要一起构建,需要使用Visual Studio构建任务

因此,删除 .Net Core Restore.Net Core build tasks 并添加 NuGet Tool Installer ( 4.3.0)Nuget restoreVisual Studio Build 任务(Visual Studio 版本:最新或Visual Studio 2017)

如果要在构建期间生成部署包,可以像这样指定 MSBuild 参数:

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)"