【问题标题】:Azure Service Fabric unable to do CI on VSTS with ASP.NET CoreAzure Service Fabric 无法使用 ASP.NET Core 在 VSTS 上执行 CI
【发布时间】:2017-10-20 09:27:10
【问题描述】:

我创建了基于 Service Fabric 的系统,并在生产环境(和开发)上工作。一切都好。现在,我尝试使用为 ASF 项目提供的模板在 Visual Studio Team Services 上设置 CI。 不幸的是,我的系统有 Actors (.NET 4.5.2) 和基于 ASP.NET Core 1.1 的 WebAPI。我在 .NET Core 中引用了 Actor 接口项目(也是 .NET 4.5.2)。

当我尝试使用默认模板构建项目时,我收到错误,因为 dotnet restore 未运行。好的,所以我添加了运行 dotnet restore 的步骤,但后来我收到错误消息,抱怨它找不到对 Actor.Interfaces 的引用。

dotnet restore 在我的开发机器上也失败,但使用 VS 构建解决方案正常。

我该如何解决这个问题?

[更新]

感谢 Mardoxx,我已经取得了一些进展......现在我遇到了 *.sln buld 的错误。我的解决方案是 VS2015(在构建任务中设置),我已将 env 设置为 Hosted VS2017。

IntegrationApi\IntegrationApi.xproj(7,11): Error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\DotNet\Microsoft.DotNet.Props" was not found. Also, tried to find "DotNet\Microsoft.DotNet.Props" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\msbuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.
Project "d:\a\1\s\Labelcall.sln" (1) is building "d:\a\1\s\IntegrationApi\IntegrationApi.xproj" (18) on node 1 (default targets).
d:\a\1\s\IntegrationApi\IntegrationApi.xproj(7,11): error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\DotNet\Microsoft.DotNet.Props" was not found. Also, tried to find "DotNet\Microsoft.DotNet.Props" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\msbuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.
Done Building Project "d:\a\1\s\IntegrationApi\IntegrationApi.xproj" (default targets) -- FAILED.

[更新2]

在采取 starain-MSFT 提出的步骤后,我在“dotnet restore”期间遇到错误:

log  : Restoring packages for d:\a\1\s\AdminPanel\project.json...
error: Unable to resolve 'AccountActor.Interfaces' for 
'.NETFramework,Version=v4.5.2'.
error: Unable to resolve 'CommonContracts' for 
'.NETFramework,Version=v4.5.2'.
error: Unable to resolve 'CommonInfrastructure' for 
'.NETFramework,Version=v4.5.2'.

[更新3]

@starain 输入后的另一个更新。

现在我收到错误,无法找到引用(来自 Core 项目的 .NET 4.5.2 项目)。

        Project "d:\a\1\s\LabelcallApplication\LabelcallApplication.sfproj" (2) is building "d:\a\1\s\MobileApi\MobileApi.xproj" (19) on node 1 (default targets).
    PrepareForBuild:
      Creating directory ".\bin\".
      Creating directory ".\obj\Release\".
    PreComputeCompileTypeScript:
      C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.0\tsc.exe  --noEmitOnError --listEmittedFiles
    CompileTypeScript:
      C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.0\tsc.exe  --noEmitOnError --listEmittedFiles
    CoreCompile:
      C:\Program Files\dotnet\dotnet.exe build "d:\a\1\s\MobileApi" --configuration Release --no-dependencies
      Project MobileApi (.NETFramework,Version=v4.5.2) will be compiled because expected outputs are missing
      Compiling MobileApi for .NETFramework,Version=v4.5.2
      C:\Program Files\dotnet\dotnet.exe compile-csc @d:\a\1\s\MobileApi\obj\Release\net452\dotnet-compile.rsp returned Exit Code 1
    MobileApi\project.json(6,44): Warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.DependencyCollector 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0
    d:\a\1\s\MobileApi\project.json(6,44): warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.DependencyCollector 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0 [d:\a\1\s\MobileApi\MobileApi.xproj]
    MobileApi\project.json(6,44): Warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.PerfCounterCollector 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0
    d:\a\1\s\MobileApi\project.json(6,44): warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.PerfCounterCollector 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0 [d:\a\1\s\MobileApi\MobileApi.xproj]
    MobileApi\project.json(6,44): Warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0
    d:\a\1\s\MobileApi\project.json(6,44): warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0 [d:\a\1\s\MobileApi\MobileApi.xproj]
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): Error : d:\a\1\s\MobileApi\error CS0006: Metadata file 'd:\a\1\s\ContactActor.Interfaces\bin\Release\ContactActor.Interfaces.dll' could not be found
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : d:\a\1\s\MobileApi\error CS0006: Metadata file 'd:\a\1\s\ContactActor.Interfaces\bin\Release\ContactActor.Interfaces.dll' could not be found [d:\a\1\s\MobileApi\MobileApi.xproj]
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): Error : d:\a\1\s\MobileApi\error CS0006: Metadata file 'd:\a\1\s\DeviceActor.Interfaces\bin\Release\DeviceActor.Interfaces.dll' could not be found
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : d:\a\1\s\MobileApi\error CS0006: Metadata file 'd:\a\1\s\DeviceActor.Interfaces\bin\Release\DeviceActor.Interfaces.dll' could not be found [d:\a\1\s\MobileApi\MobileApi.xproj]
      Compilation failed.
          3 Warning(s)
          2 Error(s)
      Time elapsed 00:00:01.7675632

【问题讨论】:

  • 确保你的构建环境是VS2017!对于托管机器:visualstudio.com/en-us/docs/build/concepts/agents/…
  • 您还需要为服务结构项目添加一个执行msbuild /t:restore 的构建任务以提取其依赖项 - 尚不支持新的 csproj 格式,因此它仍使用旧方法 (afaik)。跨度>
  • 谢谢,我已经更新了我的问题。
  • 如果你还在为你的 .net 内核使用 VS2015 和 xproj,我认为你不能使用 VS2017 托管代理。尝试回到 VS2015 并首先构建 actor 项目,然后执行 dotnet restore 然后构建解决方案。

标签: c# azure asp.net-core azure-service-fabric azure-pipelines


【解决方案1】:

请参考以下步骤:

  1. 使用 Azure Service Fabric 应用程序模板创建新的生成定义
  2. 将 Visual Studio 版本更改为 Visual Studio 2015 以执行 Visual Studio 构建步骤。
  3. 选择 NuGet 安装程序步骤/任务,在 高级 部分将 NuGet 版本更改为 3.5.0
  4. 选择选项选项卡并将默认代理队列更改为托管
  5. 使用托管代理构建队列。 (未托管 VS 2017)

所有构建步骤:

  1. NuGet 安装程序(NuGet 恢复 ***.sln)
  2. .Net Core(dotnet 恢复)
  3. Visual Studio 构建(构建解决方案 ***.sln)
  4. Visual Studio 构建(构建解决方案 ***.sfproj)
  5. 复制文件
  6. 删除文件
  7. 更新 Service Fabric 应用版本
  8. 复制文件
  9. 发布构建工件

【讨论】:

  • 不幸的是,我在 dotnet restore 期间遇到错误(请参阅更新的问题)
  • @michajas 使用 NuGet 3.5.0 版本。 (删除 .Net Core 步骤/任务。我更新了答案)
  • @michajas 你能把整个构建日志贴在这里或者分享到 OneDrive 上吗?尝试右键单击解决方案 > 项目依赖项并检查 MobileApi 的依赖项。另一方面,您可以在 OneDrive 上分享一个可以重现此问题的简单项目。
猜你喜欢
  • 1970-01-01
  • 2018-08-20
  • 2018-09-15
  • 2023-04-06
  • 2016-09-28
  • 2018-02-22
  • 1970-01-01
  • 2017-06-08
  • 2018-01-23
相关资源
最近更新 更多