首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NETSDK1061:项目是使用Microsoft.NETCore.App版本1.0.0还原的,但使用当前设置时,将改用版本2.0.9

NETSDK1061:项目是使用Microsoft.NETCore.App版本1.0.0还原的,但使用当前设置时,将改用版本2.0.9
EN

Stack Overflow用户
提问于 2018-12-11 17:07:22
回答 10查看 15.5K关注 0票数 26

我正在开发一个移动应用程序,并使用微软应用程序中心的CI。昨天,单元测试项目在App Center中构建失败,出现以下错误。我不能在任何开发者机器上重现这个问题,这个错误只在App Center中出现。

代码语言:javascript
复制
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.

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

EN

回答 10

Stack Overflow用户

发布于 2019-01-18 01:02:33

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

代码语言:javascript
复制
<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>
票数 36
EN

Stack Overflow用户

发布于 2019-03-28 12:37:57

如果你使用Azure DevOps,不要编辑项目文件。使用"dotnet restore"(https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/dotnet-core?view=azure-devops)代替Nuget restore:

替换为:

代码语言:javascript
复制
- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

有了这个:

代码语言:javascript
复制
- script: dotnet restore
票数 11
EN

Stack Overflow用户

发布于 2019-04-10 06:04:51

我在Visual Studio 2019上。当我第二次尝试将我的项目发布为自包含项目时,我遇到了这个问题。

为了消除这个错误,我所做的是:

将项目的部署模式更改为框架Dependent

  • Publish
  • 将其更改回自包含并再次发布

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

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53720678

复制
相关文章

相似问题

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