我们有一个 aspnet-core
应用程序,它由多个 .net 标准
库、两个 aspnet-core mvc
应用程序组成,并且,特别的是, .net Framework
控制台应用程序。
这些都成功构建,无论是在 Visual Studio 的解决方案中,还是单独使用 msbuild
/dotnet build
命令。
我们现在正在尝试使用 VSTS 实现持续集成/构建。
我们发现 aspnet-core
Web 应用程序构建成功,但 .net Framework
控制台应用程序失败并出现多个错误消息,如下所示:
2017-12-24T07:20:26.4090447Z C:\Program
Files\dotnet\sdk\2.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\1\s\WinApps\ListBuilder\ListBuilder.csproj]
C:\Program Files\dotnet\sdk\2.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\1\s\WinApps\TelemListBuilder\TelemListBuilder.csproj]
控制台应用程序遵循与 Web 应用程序相同的文件夹结构,但似乎无法找到任何引用的包。
我们的代理队列是托管VS2017
。
我们有两个 VSTS 任务:从 asp.net core
构建模板进行Restore
和Build
。
如果有必要,如果我们可以从构建中排除控制台应用程序,我们会很高兴。
最佳答案
由于存在通用.net Framework项目和.net core项目,并且您希望将它们一起构建,因此您需要使用Visual Studio Build任务。
因此,删除.Net Core Restore和.Net Core构建任务并添加NuGet Tool Installer (4.3.0),< strong>Nuget 恢复 和 Visual Studio Build 任务(Visual Studio 版本:最新或 Visual Studio 2017)
如果要在构建过程中生成部署包,可以指定 MSBuild 参数,如下所示:
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)"
关于continuous-integration - VSTS 构建中的混合目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48059129/