这是一个普通的控制台应用程序,我已经在我的电脑上安装了NET.CORE,看看dotnet的结果--info
.NET SDK (reflecting any global.json):
Version: 5.0.202
Commit: db7cc87d51
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.202\
Host (useful for support):
Version: 5.0.5
Commit: 2f740adc14
.NET SDKs installed:
1.0.0-preview2-003131 [C:\Program Files\dotnet\sdk]
3.1.408 [C:\Program Files\dotnet\sdk]
5.0.102 [C:\Program Files\dotnet\sdk]
5.0.104 [C:\Program Files\dotnet\sdk]
5.0.202 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
这是我的项目文件,另外我找到了System.Runtime.dll的所有位置并将其包含在项目文件的路径中。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<RootNamespace>LinuxCamelCase</RootNamespace>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ReferencePath>C:\Program Files\dotnet\sdk\3.1.408\;C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.14;C:\Program Files\dotnet\sdk\3.1.408\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1</ReferencePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MySqlConnector" Version="1.3.8" />
</ItemGroup>
</Project>
然而,在Visual Studio 2019中编译是不可能的。
1>J:\Vs2019\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Could not load file or assembly 'System.Runtime.Intrinsics.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
1>J:\Vs2019\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Could not load file or assembly 'System.Runtime.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
1>vbc : error BC30002: Type 'System.Void' is not defined.
1>vbc : error BC30002: Type 'System.Void' is not defined.
1>vbc : error BC30002: Type 'System.String' is not defined.
1>vbc : error BC30002: Type 'System.String' is not defined.
1>vbc : error BC30002: Type 'System.Void' is not defined.
1>vbc : error BC30002: Type 'System.Object' is not defined.
1>vbc : error BC30002: Type 'System.Object' is not defined.
1>vbc : error BC30652: Reference required to assembly '<Missing Core Assembly>, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' containing the type 'Object'. Add one to your project.
1>vbc : error BC30652: Reference required to assembly '<Missing Core Assembly>, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' containing the type 'Object'. Add one to your project.
dotnet-core-uninstall
This tool cannot uninstall versions of the runtime or SDK that are
- SDKs installed using Visual Studio 2019 Update 3 or later.
- SDKs and runtimes installed via zip/scripts.
- Runtimes installed with SDKs (these should be removed by removing that SDK).
The versions that can be uninstalled with this tool are:
.NET Core SDKs:
5.0.202 x64 [Used by Visual Studio. Specify individually or use --force to remove]
5.0.104 x64
3.1.408 x86
3.1.408 x64
1.0.1 x64 [Used by Visual Studio. Specify individually or use --force to remove]
.NET Core Runtimes:
3.1.14 x64
2.1.27 x64
ASP.NET Core Runtimes:
5.0.5 x86
5.0.5 x64
3.1.14 x86
2.1.27 x64
.NET Core Runtime & Hosting Bundles:
当然,在安装VS2019的过程中,我选择了.NET核心开发。但是现在我只有一种编译的选择
<TargetFramework>net5.0</TargetFramework>
编译其他框架叉是不可能的。为什么?
我不想从NET 3.1迁移到NET 5.0,也不想在我的Linux主机环境中支持NET CORE 5.0,因为我有很多历史应用程序,我不想在Linux主机上有很多不同版本的NET CORE。
我希望这只是一个bug,而不是微软的政策--不要允许开发人员保存首选的NET CORE版本。
发布于 2021-05-08 21:44:46
你是否启动了Visual Studio Installer,点击Modify按钮,如下所示:
首先,确保您选择了.NET桌面开发工作负载:
然后滚动到该页面的底部,选择.NET核心跨平台开发包,如下所示:
确保并单击install按钮,等待安装完成。这很有可能解决您的问题。
https://stackoverflow.com/questions/67446012
复制相似问题