管道构建失败,但Visual Studio构建成功

时间:2019-02-16 21:19:30

标签: azure-devops

我正在努力使我的构建Devops Pipelines自动化。我的Visual Studio(15.9.7)构建成功,但是当我在Devops Pipelines中尝试构建时,出现错误:

    Error : NETSDK1061: The project was restored using
    Microsoft.NETCore.App version 1.0.0,
    but with current settings, version 2.1.0 would be used instead. 
    To resolve this issue, make sure the same settings are used for 
    restore and for subsequent operations such as build or publish. 
    Typically this issue can occur if the RuntimeIdentifier property is 
    set during build or publish but not during restore. For more
    information, see 
    https://aka.ms/dotnet-runtime-patch-selection.

我尝试使用Microsoft构建代理(VS2017)以及从Visual Studio成功构建计算机。在这两种情况下,我都会遇到相同的错误。

我一直在使用对所有文件的文本搜索来查找对Microsoft.NETCore.App的引用,但没有找到对1.0.0的引用。

作为另一个数据点,这是我的dotnet --info输出:         .NET Core SDK(反映任何global.json):         版本:2.2.103         提交:8edbc2570a

    Runtime Environment:
    OS Name:     Windows
    OS Version:  10.0.17134
    OS Platform: Windows
    RID:         win10-x64
    Base Path:   C:\Program Files\dotnet\sdk\2.2.103\

    Host (useful for support):
      Version: 2.2.1
      Commit:  878dd11e62

    .NET Core SDKs installed:
      2.1.503 [C:\Program Files\dotnet\sdk]
      2.1.504 [C:\Program Files\dotnet\sdk]
      2.2.103 [C:\Program Files\dotnet\sdk]

    .NET Core runtimes installed:
      Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
      Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
      Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
      Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

    To install additional .NET Core runtimes or SDKs:
      https://aka.ms/dotnet-download

1 个答案:

答案 0 :(得分:0)

我的问题的解决方案原来是在another question中的StackOverflow中,我在原始搜索中没有找到。解决方法是:

  • 将RuntimeIdentifiers属性设置为所有要发布的RID的分号分隔列表。
  • 将TargetLatestRuntimePatch属性设置为true。