首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NETSDK1061:使用Microsoft.AspNetCore.All版本2.0.5还原了该项目,但在当前设置下,将使用2.0.4版本

NETSDK1061:使用Microsoft.AspNetCore.All版本2.0.5还原了该项目,但在当前设置下,将使用2.0.4版本
EN

Stack Overflow用户
提问于 2019-04-27 00:18:56
回答 1查看 686关注 0票数 0

在试图通过Visual 2019年中的nuget管理器更新一些包之后,我正在尝试构建一个解决方案,最后出现了以下错误:

代码语言:javascript
复制
error : NETSDK1061: The project was restored using Microsoft.AspNetCore.All version 2.0.5, but with current settings, version 2.0.4 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. 

我检查了this answer on SO,但我不太明白给出的解决方案如何能帮助我解决这个问题:

您需要设置相同的发布和构建运行时。 netcoreapp2.1 2.1.0 ->修复发布问题AnyCPU ->修复发布问题->修复构建问题

完整的dotnet build日志:

代码语言:javascript
复制
λ dotnet build
Microsoft (R) Build Engine version 16.0.450+ga8dc7f1d34 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 40.89 ms for C:\Users\eperret\Desktop\KYC\KYC.Utils\KYC.Utils.csproj.
  Restore completed in 40.89 ms for C:\Users\eperret\Desktop\KYC\KYC.Core.DAL\KYC.Core.DAL.csproj.
  Restore completed in 80.13 ms for C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj.
C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj : warning NU1603: KYC.Core depends on Microsoft.AspNetCore.All (>= 2.0.4) but Microsoft.AspNetCore.All 2.0.4 was not found. An approximate best match of Microsoft.AspNetCore.All 2.0.5 was resolved.
  Restore completed in 66.57 ms for C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj.
C:\Program Files\dotnet\sdk\2.2.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(153,5): warning NETSDK1071: A PackageReference to 'Microsoft.AspNetCore.All' specified a Version of `2.0.4`. Specifying the version of this package is not recommended. For more information, see https://aka.ms/sdkimplicitrefs [C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj]
C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj : warning NU1603: KYC.Core depends on Microsoft.AspNetCore.All (>= 2.0.4) but Microsoft.AspNetCore.All 2.0.4 was not found. An approximate best match of Microsoft.AspNetCore.All 2.0.5 was resolved.
C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj : error : NETSDK1061: The project was restored using Microsoft.AspNetCore.All version 2.0.5, but with current settings, version 2.0.4 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.

Build FAILED.

C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj : warning NU1603: KYC.Core depends on Microsoft.AspNetCore.All (>= 2.0.4) but Microsoft.AspNetCore.All 2.0.4 was not found. An approximate best match of Microsoft.AspNetCore.All 2.0.5 was resolved.
C:\Program Files\dotnet\sdk\2.2.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(153,5): warning NETSDK1071: A PackageReference to 'Microsoft.AspNetCore.All' specified a Version of `2.0.4`. Specifying the version of this package is not recommended. For more information, see https://aka.ms/sdkimplicitrefs [C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj]
C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj : warning NU1603: KYC.Core depends on Microsoft.AspNetCore.All (>= 2.0.4) but Microsoft.AspNetCore.All 2.0.4 was not found. An approximate best match of Microsoft.AspNetCore.All 2.0.5 was resolved.
C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj : error : NETSDK1061: The project was restored using Microsoft.AspNetCore.All version 2.0.5, but with current settings, version 2.0.4 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.
    3 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.52

我的KYC.Core包含:

代码语言:javascript
复制
  <ItemGroup>
    <PackageReference Include="bootstrap" Version="4.3.1" />
    <PackageReference Include="Bootstrap.Datepicker" Version="1.8.0.1" />
    <PackageReference Include="jQuery" Version="3.3.1" />
    <PackageReference Include="jQuery.UI.Combined" Version="1.12.1" />
    <PackageReference Include="jQuery.Validation" Version="1.17.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.4" />
    <PackageReference Include="Microsoft.AspNetCore" Version="2.0.2" />
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.4" />
    <PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Owin" Version="2.2.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" />
    <PackageReference Include="Microsoft.Extensions.Localization" Version="2.1.1" />
    <PackageReference Include="Microsoft.jQuery.Unobtrusive.Ajax" Version="3.2.5" />
    <PackageReference Include="Microsoft.jQuery.Unobtrusive.Validation" Version="3.2.11" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.3" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Utils" Version="2.0.3" />
    <PackageReference Include="RazorEngine.Core.NetCore" Version="4.5.0-rc1" />
    <PackageReference Include="RestSharp" Version="106.6.9" />
    <PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
    <PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
    <PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
    <PackageReference Include="Serilog.Sinks.ElasticSearch" Version="7.1.0" />
  </ItemGroup>

编辑

我试图删除<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.4" />的版本,但实际上没有帮助:

代码语言:javascript
复制
λ dotnet build
Microsoft (R) Build Engine version 16.0.450+ga8dc7f1d34 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 39.63 ms for C:\Users\eperret\Desktop\KYC\KYC.Core.DAL\KYC.Core.DAL.csproj.
  Restore completed in 37.36 ms for C:\Users\eperret\Desktop\KYC\KYC.Utils\KYC.Utils.csproj.
  Restore completed in 73.48 ms for C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj.
C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj : error NU1107: Version conflict detected for Microsoft.CodeAnalysis.CSharp. Install/reference Microsoft.CodeAnalysis.CSharp 2.8.0 directly to project KYC.Core to resolve this issue.
C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj : error NU1107:  KYC.Core -> Microsoft.AspNetCore.Mvc 2.2.0 -> Microsoft.AspNetCore.Mvc.Razor.Extensions 2.2.0 -> Microsoft.CodeAnalysis.Razor 2.2.0 -> Microsoft.CodeAnalysis.CSharp (>= 2.8.0)
C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj : error NU1107:  KYC.Core -> RazorEngine.Core.NetCore 4.5.0-rc1 -> Microsoft.CodeAnalysis 2.3.2 -> Microsoft.CodeAnalysis.CSharp.Workspaces 2.3.2 -> Microsoft.CodeAnalysis.CSharp (= 2.3.2).
  Restore failed in 1.19 sec for C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj.

Build FAILED.

C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj : error NU1107: Version conflict detected for Microsoft.CodeAnalysis.CSharp. Install/reference Microsoft.CodeAnalysis.CSharp 2.8.0 directly to project KYC.Core to resolve this issue.
C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj : error NU1107:  KYC.Core -> Microsoft.AspNetCore.Mvc 2.2.0 -> Microsoft.AspNetCore.Mvc.Razor.Extensions 2.2.0 -> Microsoft.CodeAnalysis.Razor 2.2.0 -> Microsoft.CodeAnalysis.CSharp (>= 2.8.0)
C:\Users\eperret\Desktop\KYC\KYC.Core\KYC.Core.csproj : error NU1107:  KYC.Core -> RazorEngine.Core.NetCore 4.5.0-rc1 -> Microsoft.CodeAnalysis 2.3.2 -> Microsoft.CodeAnalysis.CSharp.Workspaces 2.3.2 -> Microsoft.CodeAnalysis.CSharp (= 2.3.2).
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:02.41
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-27 16:16:19

好的,我的技巧是卸载几乎所有的东西,直到解决方案不再编译为止,因为我怀疑有几个软件包是完全无用的(我继承了一些遗留的)。然后,我只是重新安装软件包,只是需要构建解决方案,这一次起了作用。

代码语言:javascript
复制
  <ItemGroup>
    <PackageReference Include="bootstrap" Version="4.3.1" />
    <PackageReference Include="Bootstrap.Datepicker" Version="1.8.0.1" />
    <PackageReference Include="jQuery" Version="3.3.1" />
    <PackageReference Include="jQuery.UI.Combined" Version="1.12.1" />
    <PackageReference Include="jQuery.Validation" Version="1.17.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.All" />
    <PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Owin" Version="2.2.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" />
    <PackageReference Include="Microsoft.jQuery.Unobtrusive.Ajax" Version="3.2.6" />
    <PackageReference Include="Microsoft.jQuery.Unobtrusive.Validation" Version="3.2.11" />
    <PackageReference Include="RazorEngine.NetCore" Version="2.2.2" />
    <PackageReference Include="RestSharp" Version="106.6.9" />
    <PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
    <PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
    <PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
    <PackageReference Include="Serilog.Sinks.ElasticSearch" Version="7.1.0" />
  </ItemGroup>

问题就在那些包裹里

  • Microsoft.VisualStudio.Web.CodeGeneration.Design:不需要
  • Microsoft.VisualStudio.Web.CodeGeneration.Utils:不需要
  • RazorEngine.Core.NetCore:使用RazorEngine.NetCore代替
  • Microsoft.AspNetCore.All:不需要指示版本,请使用最新版本
  • Microsoft.AspNetCore:升级到2.2.0
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55876220

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档