繁体   English   中英

Asp.NET 核心项目因 NETSDK1061 失败:项目已使用 Microsoft.NETCore.App 版本恢复

[英]Asp.NET core project fails with NETSDK1061: The project was restored using Microsoft.NETCore.App version

我的一个开源项目刚刚开始因错误而无法构建,而以前它曾经成功构建(如果我为以前成功的提交触发构建,我仍然会收到此错误)

C:\projects\formfactory\FormFactory.AspNetCore.Example\FormFactory.AspNetCore.Example.csproj: error: NETSDK1061: The project was restored using Microsoft.NETCore.App version 2.2.4, but with current settings, version 2.2.1 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.

完整的构建日志在这里

csproj 看起来像这样:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <AssemblyName>FormFactory.AspNetCore.Example</AssemblyName>
    <OutputType>Exe</OutputType>
    <PackageId>FormFactory.AspNetCore.Example</PackageId>
    <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>

    <MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
  </PropertyGroup>

  <ItemGroup>
    <None Update="wwwroot\**\*;Views\**\*;Areas\**\Views">
      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    </None>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\FormFactory\FormFactory.csproj" />
    <ProjectReference Include="..\FormFactory.AspNetCore\FormFactory.AspNetCore.csproj" />
  </ItemGroup>

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

  <Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
    <Exec Command="bower install" />
    <Exec Command="dotnet bundle" />
  </Target>

  <ItemGroup>
    <DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.2.301" />
  </ItemGroup>

</Project>

来自https://github.com/mcintyre321/FormFactory/blob/master/FormFactory.AspNetCore.Example/FormFactory.AspNetCore.Example.csproj

我需要做什么来解决这个问题?

尝试从Microsoft.AspNetCore.All package 中删除显式版本 - 该版本应由 SDK (隐式版本)确定,因为您还使用TargetLatestRuntimePatch设置。 在指定显式元包版本时出现类似问题。

此外,您可能需要考虑按照建议将其交换到Microsoft.AspNetCore.App - 减少第 3 方依赖项。 在此处阅读更多信息: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/metapackage-app?view=aspnetcore-2.2

我已通过将构建服务器环境从 VS2017 更改为 VS2019 来解决此问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM