【问题标题】:How to fix MSBuild error NU1607: Version conflict detected?如何修复 MSBuild 错误 NU1607:检测到版本冲突?
【发布时间】:2019-11-06 03:38:07
【问题描述】:

我的 Web API .Net Core 2.2 项目在 VS 2019 中构建没有错误。但是,当我尝试在 TFS 2018 构建服务器中构建它时,在 NuGet 还原步骤中出现以下错误:

NU1607: Version conflict detected for Microsoft.AspNetCore.Hosting.Abstractions. Reference the package directly from the project to resolve this issue. MyWebAPIProject (>= 1.0.0) -> NLog.Web.AspNetCore (>= 4.8.6) -> Microsoft.AspNetCore.Hosting.Abstractions (>= 2.1.1) MyWebAPIProject (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0) -> Microsoft.AspNetCore.Hosting.Abstractions (>= 2.1.0).
我将 Microsoft.AspNetCore.Hosting.Abstractions 版本 2.2.0 NuGet 包添加到 MyWebAPIProject。现在,MyWebAPIProject.cproj 文件看起来像这样

<Project Sdk="Microsoft.NET.Sdk.Web">
  <!--<PropertyGroup Label="Globals">
    <SccProjectName>SAK</SccProjectName>
    <SccProvider>SAK</SccProvider>
    <SccAuxPath>SAK</SccAuxPath>
    <SccLocalPath>SAK</SccLocalPath>
  </PropertyGroup>-->

  <PropertyGroup Label="Globals">
    <SccProjectName>%24/MyWebAPIProject</SccProjectName>
    <SccProvider>{AAAAAAA-AAA-AAA-AAA-AAA}</SccProvider>
    <SccAuxPath>http://TFSBuildServer:8080/tfs/defaultcollection</SccAuxPath>
    <SccLocalPath>.</SccLocalPath>
  </PropertyGroup>

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
    <UserSecretsId>adfbcb24-c16e-40ec-bf0a-45b437155743</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.Hosting.Server.Abstractions" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="2.2.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
    <PackageReference Include="NLog.Schema" Version="4.6.8" />
    <PackageReference Include="NLog.Web.AspNetCore" Version="4.8.6" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\MyWebAPI.Repository\MyWebAPI.Repository.csproj" />
    <ProjectReference Include="..\MyWebAPI.Interfaces\MyWebAPI.Interfaces.csproj" />
  </ItemGroup>

</Project>`      

但是,MSBuild 仍然失败并出现同样的错误。有人可以帮忙吗?谢谢。

【问题讨论】:

    标签: asp.net-core nuget-package-restore


    【解决方案1】:

    我的项目 TFS 构建步骤“使用 Nuget x.x.x”被配置为使用 4.3.0 版本。 4.3.0 是创建新 TFS 构建时的默认版本。我在 要安装的 NuGet.exe 版本 框中将 NuGet.exe 版本更改为 4.6.0,以使其与 NuGet 包管理器的 VS 2017 帮助/关于窗口中显示的相同。版本冲突在那之后就消失了。但是,当我像在 VS2019 中一样将 NuGetexe 版本设置为 5.3.1 时,弹出了与 dotnet sdk 3.0 相关的错误。因此,我将版本更改回 4.6.0。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-16
      • 1970-01-01
      • 1970-01-01
      • 2023-01-13
      • 2018-01-12
      • 1970-01-01
      相关资源
      最近更新 更多