【发布时间】:2022-01-25 23:21:24
【问题描述】:
我的解决方案是:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core31ConsoleApp", "Core31ConsoleApp\Core31ConsoleApp.csproj", "{06477443-295A-47CA-A36E-A3F6B3AE47AC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{06477443-295A-47CA-A36E-A3F6B3AE47AC}.Debug|x64.ActiveCfg = Debug|x64
{06477443-295A-47CA-A36E-A3F6B3AE47AC}.Debug|x64.Build.0 = Debug|x64
{06477443-295A-47CA-A36E-A3F6B3AE47AC}.Debug|x86.ActiveCfg = Debug|x86
{06477443-295A-47CA-A36E-A3F6B3AE47AC}.Debug|x86.Build.0 = Debug|x86
{06477443-295A-47CA-A36E-A3F6B3AE47AC}.Release|x64.ActiveCfg = Release|x64
{06477443-295A-47CA-A36E-A3F6B3AE47AC}.Release|x64.Build.0 = Release|x64
{06477443-295A-47CA-A36E-A3F6B3AE47AC}.Release|x86.ActiveCfg = Release|x86
{06477443-295A-47CA-A36E-A3F6B3AE47AC}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {17BBBF08-C7F4-4F6A-AD8F-32F2F3F21D27}
EndGlobalSection
EndGlobal
控制台项目是:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x86;x64</Platforms>
</PropertyGroup>
</Project>
此项目仅包含一个包含其默认内容的 C#“Program.cs”文件:
using System;
namespace Core31ConsoleApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
如您所见,它或多或少是为 .Net Core 3.1 创建的新控制台应用程序。我所做的唯一修改是用 x86 和 x64 替换了“任何 CPU”架构。可以使用 VS 成功构建 Release/Debug 和 x86/x64 的所有组合。
当我从 cmd/powershell 尝试以下两个命令中的任何一个时,它也会成功构建。
dotnet build Core31ConsoleApp.sln --configuration Debug --runtime win-x64
dotnet build Core31ConsoleApp.sln --configuration Release --runtime win-x64
当我尝试这两个之一时,问题就开始了:
dotnet build Core31ConsoleApp.sln --configuration Release --runtime win-x86
dotnet build Core31ConsoleApp.sln --configuration Debug --runtime win-x86
它们失败并出现以下错误消息:
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(151,5): error NETSDK1032: The RuntimeIdentifier platform 'win-x86 ' 和 PlatformTarget 'x64' 必须兼容。
这是重现此问题的最小解决方案,但我有一个更大且配置相同的解决方案,但失败的方式有点不同:
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(151,5): error NETSDK1032: The RuntimeIdentifier platform 'win-x64 ' 并且 PlatformTarget 'x86' 必须兼容。**
前两个命令失败,第二对有效。这可能是因为较大的解决方案在本节中有不同的顺序:
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
我正在使用在最近的 VS 更新之一期间安装了 VS2019 和 .Net Core 3.1 SDK(64 位)的 Win 10 Prof 机器(英特尔的 I7)。系统和安装的所有软件都是最新的。
我完全不知道这里出了什么问题或者我做错了什么。
如果有任何帮助,我将不胜感激。
【问题讨论】:
标签: .net-core