[英]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:我不确定为什么或如何工作,但我偶然发现了一个解决方案:
<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" />
<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.