【发布时间】:2021-05-08 09:26:21
【问题描述】:
这是一个普通的控制台应用程序,我已经在我的电脑上安装了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-卸载
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 CORE开发。 但是现在我只有一个编译选项
<TargetFramework>net5.0</TargetFramework>
无法编译其他 framefork。为什么?
我不想从 NET 3.1 迁移到 NET 5.0,也不想在我的 Linux 托管环境中支持 NET CORE 5.0,因为我有很多历史应用程序,我不想要很多不同Linux 主机中的 NET CORE 版本。
我希望这只是错误而不是 Microsoft 政策 - 不允许开发人员保存首选版本的 NET CORE。
【问题讨论】:
-
安装 vs2019 时是否包含了 .net core 工作负载?
-
@sommmen 再次检查,谢谢,现在VS需要更新。
-
如果它已修复,请发布答案并将其标记为已回答 - 或者如果这是一个真正简单的故障排除步骤,请删除问题(即,如果可以,将其保留在网站上没有价值)。
-
@sommmen 我已经从头开始重新安装了 VS2019,但没有任何改变。
标签: .net-core visual-studio-2019