NETSDK1061:使用Microsoft.NETCore.App版本1.0.0恢复项目,但使用当前设置,将使用版本2.0.9

Chr*_*ell 18 .net c# xamarin visual-studio-app-center

我正在开发一个移动应用程序并使用MS App Center for CI.昨天单元测试项目无法在App Center中构建,但出现以下错误.我无法在任何开发人员计算机上重新创建此问题,此错误仅在App Center中出现.

error : NETSDK1061: The project was restored using Microsoft.NETCore.App version 1.0.0, but with current settings, version 2.0.9 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.
Run Code Online (Sandbox Code Playgroud)

他们的付费支持只是提供基础,清理项目,回滚我的最后一次提交等.有人在App Center之前遇到过这个问题吗?

Pav*_*iuk 20

您需要设置相同的发布和构建运行时

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <RuntimeFrameworkVersion>2.1.0</RuntimeFrameworkVersion> --> fix publishing issues
    <PlatformTarget>AnyCPU</PlatformTarget> --> fix publishing issues
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Update="Microsoft.NETCore.App" Version="2.1.0" /> --> fix building issues
    <ProjectReference Include="..\PublicSonar.Monitor.Persistent.Json\PublicSonar.Monitor.Persistent.Json.csproj" />
  </ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)


小智 9

如果您使用Azure DevOps,请不要编辑项目文件。使用“ dotnet恢复”(https://docs.microsoft.com/zh-cn/azure/devops/pipelines/languages/dotnet-core?view=azure-devops)代替Nuget恢复:

替换为:

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'
Run Code Online (Sandbox Code Playgroud)

有了这个:

- script: dotnet restore
Run Code Online (Sandbox Code Playgroud)


小智 8

我使用的是 Visual Studio 2019。当我第二次尝试将我的项目作为独立项目发布时,我遇到了这个问题。

我为消除此错误所做的操作是:

  • 将部署模式更改为依赖于框架
  • 发布项目
  • 将其更改回独立并再次发布

这似乎是由一些错误的缓存引起的,可以通过切换到不同的部署模式来清除该缓存。


Ami*_*azi 5

尝试添加<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>到您的<PropertyGroup>标签。例子 :

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
    <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
  </PropertyGroup>
Run Code Online (Sandbox Code Playgroud)


小智 5

将其添加到 .csproj 中

<PropertyGroup>
<RuntimeFrameworkVersion>2.1.5</RuntimeFrameworkVersion>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)