DevOps Nu1607 NU1607:如果未指定AspNetCore版本,则检测到版本冲突

时间:2019-01-28 21:18:31

标签: asp.net-core azure-devops

我的项目正在构建中,没有错误但有警告

  

NETSDK1071对“ Microsoft.AspNetCore.App”的PackageReference指定了2.1.1的版本。不建议指定此软件包的版本。有关更多信息,请参见https://aka.ms/sdkimplicitrefs

所以我编辑了项目并进行了更改

  <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1"/>

 <PackageReference Include="Microsoft.AspNetCore.App" />

我推送了代码,然后触发了devop的构建。

但是在Devops中,我遇到了以下构建错误

The nuget command failed with exit code(1) and error(NU1607: Version conflict detected for Microsoft.AspNetCore.Razor.Language. Reference the package directly from the project to resolve this issue. 
 ServerSideTests (>= 1.0.0) -> ApiForMe3 (>= 1.0.0) -> Microsoft.VisualStudio.Web.CodeGeneration.Design (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGenerators.Mvc (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.Core (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.Templating (>= 2.1.6) -> Microsoft.AspNetCore.Razor.Language (>= 2.1.1) 
 ServerSideTests (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0) -> Microsoft.AspNetCore.Razor.Language (>= 2.1.0).
Errors in D:\a\1\s\ServerSideTests\ServerSideTests.csproj
    NU1607: Version conflict detected for Microsoft.AspNetCore.Razor.Language. Reference the package directly from the project to resolve this issue.
     ServerSideTests (>= 1.0.0) -> ApiForMe3 (>= 1.0.0) -> Microsoft.VisualStudio.Web.CodeGeneration.Design (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGenerators.Mvc (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.Core (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.Templating (>= 2.1.6) -> Microsoft.AspNetCore.Razor.Language (>= 2.1.1)
     ServerSideTests (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0) -> Microsoft.AspNetCore.Razor.Language (>= 2.1.0).)
Packages failed to restore

为什么构建会在Devops中失败,但在运行VS2017 15.9.6的本地计算机上不会失败?

抬头NU1607,我看到

  

NU1107(以前为NU1607)       问题       无法解决程序包之间的依赖关系约束。

Common causes
Packages with dependency constraints on exact versions do not allow other packages to increase the version if needed.

Example
Version conflict detected for NuGet.Versioning. Reference the package directly from the project to resolve this issue.
  NuGet.Packaging 3.5.0 -> NuGet.Versioning (= 3.5.0)
  NuGet.Configuration 4.0.0 -> NuGet.Versioning (= 4.0.0)

检查计算机上的sdk版本

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional>dotnet --list-sdks
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.400 [C:\Program Files\dotnet\sdk]
2.1.401 [C:\Program Files\dotnet\sdk]
2.1.402 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
2.1.500 [C:\Program Files\dotnet\sdk]
2.1.502 [C:\Program Files\dotnet\sdk]
2.1.503 [C:\Program Files\dotnet\sdk]
2.2.102 [C:\Program Files\dotnet\sdk]

2 个答案:

答案 0 :(得分:1)

我在使用TeamCity时遇到了类似的问题。

在TeamCity中,我更改了NuGet安装程序步骤的NuGet版本。

从Nuget.exe版本4.3升级到5.1

问题消失了

答案 1 :(得分:0)

我得到的错误:

The nuget command failed with exit code(1) and error(NU1607: Version conflict detected for Microsoft.AspNetCore.Http.Abstractions. Reference the package directly from the project to resolve this issue. 
 Service.Api (>= 1.0.0) -> Common.Middleware (>= 1.0.0) -> Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0) 
 Service.Api (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0) -> Microsoft.AspNetCore.Http.Abstractions (>= 2.1.0).
Errors in d:\a\1\s\src\Service.Api\Service.Api.csproj
    NU1607: Version conflict detected for Microsoft.AspNetCore.Http.Abstractions. Reference the package directly from the project to resolve this issue.
     Service.Api (>= 1.0.0) -> Common.Middleware (>= 1.0.0) -> Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
     Service.Api (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0) -> Microsoft.AspNetCore.Http.Abstractions (>= 2.1.0).)
Packages failed to restore

所以我对.csproj文件进行了更改:

<ItemGroup>
  <PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

收件人:

<ItemGroup>
  <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
</ItemGroup>

但是,这并不能解决问题。 (因此,我还原了以上更改)

因为我开始出现此错误:

(输出窗口)

>C:\Program Files\dotnet\sdk\2.2.107\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(153,5): warning NETSDK1071: A PackageReference to 'Microsoft.AspNetCore.App' specified a Version of `2.2.0`. Specifying the version of this package is not recommended. For more information, see https://aka.ms/sdkimplicitrefs

(构建管道MSBUILD任务)

Services.FastService.Api.csproj : error : NETSDK1061: The project was restored using Microsoft.NETCore.App version 1.0.0, but with current settings, version 2.2.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.

因此,我尝试了这一点:

<PropertyGroup>
  <TargetFramework>netcoreapp2.2</TargetFramework>
  <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>

正如其他人所建议的那样,例如在此线程中: Version 2.1.0-rc1 would be used instead

但这根本没有帮助我。 (所以我也回复了该更改。)

最终我意识到,因为当您为Microsoft.AspNetCore.App指定最低版本时,MSBUILD不喜欢它,所以默认的最低版本是不同的:

  1. Service.Api Common.Middleware(> = 1.0.0) Microsoft.AspNetCore.Http.Abstractions (> = 2.1.0)

  2. 通用中间件 Microsoft.AspNetCore.Http.Abstractions (> = 2.2.0)

因此,我将Common.Middleware项目中的最低版本'2.2.0'更改为'2.1.0'。< / p>

但这似乎也不能解决我所有的问题!

我也尝试过:

2.2.0

如此:

<PropertyGroup>
  <TargetFramework>netcoreapp2.2</TargetFramework>
  <RuntimeFrameworkVersion>2.2.0</RuntimeFrameworkVersion>
  <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>

但这也无济于事...

最后,我在YAML构建脚本中指定了NuGet 5.1.0的使用,并修复了该项目。

(因此赞成Jacob Sandh0j)

最终解决方案

YAML

- task: NuGetToolInstaller@0
  inputs:
    versionSpec: '5.1.0' 
    checkLatest: false
相关问题