[英]How can I open a .NET core 2.0 mvc project despite that I have .NET core 2.2?
I have created a .NET Core 2.2 MVC project, running these commands: 我创建了一个.NET Core 2.2 MVC项目,运行以下命令:
dotnet new mvc -n Test
Then, I changed this line in Test.csproj 然后,我在Test.csproj中更改了这一行
<TargetFramework>netcoreapp2.2</TargetFramework>
to 至
<TargetFramework>netcoreapp2.0</TargetFramework>
However, when I run "dotnet build", it gave me error like this: 但是,当我运行“ dotnet build”时,它给了我这样的错误:
error NU1202: Package Microsoft.AspNetCore.App 2.1.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0)
错误NU1202:软件包Microsoft.AspNetCore.App 2.1.0与netcoreapp2.0(.NETCoreApp,Version = v2.0)不兼容
Any help is appreciated. 任何帮助表示赞赏。
Using this commands, 使用此命令,
dotnet --list-sdks
List your sdk's, then uninstall all of these versions, except 2.0: 列出您的sdk,然后卸载除2.0以外的所有这些版本:
For example for OS x, it's like 例如对于OS X,就像
sudo rm -rf /usr/local/share/dotnet/sdk/2.2.103
sudo rm -rf /usr/local/share/dotnet/host/fxr/2.2.103
sudo rm -rf /usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.2.103
sudo rm -rf /usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.2.103
Then, run 然后跑
dotnet new mvc -n Test
In conclusion, if you have .NET core 2.2, you cannot open any 2.0 projects. 总之,如果您具有.NET core 2.2,则不能打开任何2.0项目。 You need to uninstall them.
您需要卸载它们。
However, as a shortcut, you can use this template. 但是,您可以使用此模板作为快捷方式。 Replace these in your csproj.
将它们替换为csproj。
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.1" />
</ItemGroup>
</Project>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.