简体   繁体   English

VS2019 错误说项目在定位 netcoreapp2.2 时定位到“netcoreapp3.1”

[英]VS2019 Error Says Project is Targetting 'netcoreapp3.1' when it is Targetting netcoreapp2.2

I have a multi-project solution that was working fine in VS2017, I've installed VS2019 and on compile I receive five error messages:我有一个在 VS2017 中运行良好的多项目解决方案,我已经安装了 VS2019,并且在编译时收到了五个错误消息:

Four of the format: This version of Microsoft.AspNetCore.App is only compatible with netcoreapp2.2 taret framework.格式之四:此版本的Microsoft.AspNetCore.App仅兼容netcoreapp2.2 taret框架。 Please target netcoreapp2.2 or chose a version of Microsoft.AspNetCore.app compatible with netcoreapp3.1请针对 netcoreapp2.2 或选择与 netcoreapp3.1 兼容的 Microsoft.AspNetCore.app 版本

And one of the format: Project '..\\project-path\\project.csproj' targets 'netcoreapp3.1;.格式之一:Project '..\\project-path\\project.csproj' 目标 'netcoreapp3.1;。 It cannot be reference by a project that targets '.NETCoreApp,Version=v2.2'它不能被以“.NETCoreApp,Version=v2.2”为目标的项目引用

Additionally if you look at the projects referenced in the error messages the Dependencies, Packages, SDK all have the yellow warning symbol on them (hover and right-click don't seem to provide additional details)此外,如果您查看错误消息中引用的项目,依赖项、包、SDK 上都有黄色警告符号(悬停和右键单击似乎没有提供其他详细信息)

I've tried cleans, delete bin and obj folders, rebuilds, checking SDK versions, but no luck我试过清理、删除 bin 和 obj 文件夹、重建、检查 SDK 版本,但没有运气

I can confirm I have a global.json with the SDK version (2.2.103) and that when in any of these projects directories and I run 'dotnet --verson' I get back 2.2.103我可以确认我有一个带有 SDK 版本 (2.2.103) 的 global.json 并且当我在这些项目目录中的任何一个中运行“dotnet --verson”时,我会返回 2.2.103

What is happening here?这里发生了什么? What / where is it picking up netcoreapp3.1 from and how do I resolve these errors?它从什么/哪里获取 netcoreapp3.1 以及如何解决这些错误?

Update: CSPROJ Details更新:CSPROJ 详细信息

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <LangVersion>7.3</LangVersion>
  </PropertyGroup>



 <ItemGroup>
    <None Include="appsettings.json" CopyToOutputDirectory="Always" />
    <None Include="favicon.ico" CopyToOutputDirectory="Always" />
    <None Include="appDevLocalOverride.json" />
    <PackageReference Include="Lamar.Microsoft.DependencyInjection" Version="3.1.0" />
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.8.1" />
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.AzureKeyVault.HostingStartup" Version="2.0.2" />
    <PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.1.2" />
    <PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.3" />
    <PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.0.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
  </ItemGroup>

I'm not sure why or how this works, but I have stumbled on a solution:我不确定为什么或如何工作,但我偶然发现了一个解决方案:

  1. Open the csproj打开 csproj
  2. Edit <PackageReference Include="Microsoft.AspNetCore.App" /> to <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" /><PackageReference Include="Microsoft.AspNetCore.App" /> to <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
  3. Build > Clean Solution构建 > 清洁解决方案
  4. Manually remove ALL bin and obj folders (even if they are only remotely related to the solution)手动删除所有 bin 和 obj 文件夹(即使它们只是与解决方案远程相关)
  5. Build > Rebuild Solution构建 > 重建解决方案
  6. Edit <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" /> to <PackageReference Include="Microsoft.AspNetCore.App" /><PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" /> to <PackageReference Include="Microsoft.AspNetCore.App" />

That seemed to work for me, why a simple Clean Solution and Rebuild wasn't the answer is odd;这似乎对我有用,为什么简单的 Clean Solution and Rebuild 不是答案很奇怪; but hopefully this will help someone else!但希望这会帮助别人!

暂无
暂无

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

相关问题 使用 VS2019 构建控制台 .netcoreapp3.1 应用程序时出错 - Error building a console .netcoreapp3.1 app with VS2019 软件包与netcoreapp2.2不兼容 - Package is not compatible with netcoreapp2.2 Azure DevOps 管道在恢复时失败 - 测试项目与 netcoreapp2.2 不兼容项目支持:netcoreapp3.0 - Azure DevOps pipeline fails at Restore - Test project is not compatible with netcoreapp2.2 Project supports: netcoreapp3.0 TFM 从 netcoreapp3.0 升级到 netcoreapp3.1 时 Azure Function 构建失败 - Azure Function fails to build when TFM is upgraded from netcoreapp3.0 to netcoreapp3.1 Package X 与 netcoreapp3.1 不兼容 - Package X is not compatible with netcoreapp3.1 Project xxx与netcoreapp2.2(.NETCoreApp,Version = v2.2)不兼容。 Project xxx支持:net48(.NETFramework,Version = v4.8) - Project xxx is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2). Project xxx supports: net48 (.NETFramework,Version=v4.8) 如何在netcoreapp3.1 worker服务项目中使用Microsoft.Extensions.Http.Polly - How to use Microsoft.Extensions.Http.Polly in netcoreapp3.1 worker service project 如何强制 Swashbuckle.Aspnetcore.Cli 使用 netcoreapp3.1? - How to force Swashbuckle.Aspnetcore.Cli to use netcoreapp3.1? 无法打开 Web 站点“bin/Debug/netcoreapp3.1/publish”。 Web 站点“bin/Debug/netcoreapp3.1/publish”不存在 - Unable to open the Web site 'bin/Debug/netcoreapp3.1/publish'. The Web site 'bin/Debug/netcoreapp3.1/publish' does not exist 为什么 netcoreapp2.1 和 netcoreapp3.1 的 TimeSpan 值不同? - Why are the TimeSpan values different between netcoreapp2.1 and netcoreapp3.1?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM