我的解决方案是:
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
Run Code Online (Sandbox Code Playgroud)
控制台项目是:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x86;x64</Platforms>
</PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
该项目仅包含一个 C#“Program.cs”文件,其中包含其默认内容:
using System;
namespace Core31ConsoleApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
Run Code Online (Sandbox Code Playgroud)
如您所见,它或多或少是为 .Net Core 3.1 创建的新控制台应用程序。我所做的唯一修改是将“Any CPU”架构替换为 x86 和 x64。它可以使用 VS 成功构建用于发布/调试和 x86/x64 的所有组合。
当我从 cmd/powershell 尝试以下两个命令中的任何一个时,它也会成功构建。
dotnet build Core31ConsoleApp.sln --configuration Debug --runtime win-x64
dotnet build Core31ConsoleApp.sln --configuration Release --runtime win-x64
Run Code Online (Sandbox Code Playgroud)
当我尝试这两者之一时,问题就开始了:
dotnet build Core31ConsoleApp.sln --configuration Release --runtime win-x86
dotnet build Core31ConsoleApp.sln --configuration Debug --runtime win-x86
Run Code Online (Sandbox Code Playgroud)
它们失败并出现以下错误消息:
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(151,5):错误NETSDK1032:RuntimeIdentifier平台'win-x86'和PlatformTarget“x64”必须兼容。
这是重现此问题的最小解决方案,但我有一个更大且配置相同的解决方案,但失败的方式有点不同:
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(151,5):错误NETSDK1032:RuntimeIdentifier平台'win-x64'和PlatformTarget“x86”必须兼容。**
它对于前两个命令失败,但对于第二对命令有效。这可能是因为较大的解决方案在本节中具有不同的顺序:
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
Run Code Online (Sandbox Code Playgroud)
我正在使用 Win 10 Prof 机器(Intel 的 I7),在最近的 VS 更新之一中安装了 VS2019 和 .Net Core 3.1 SDK(64 位)。系统和所有安装的软件都是最新的。
我完全不知道这里出了什么问题或者我做错了什么。
我将不胜感激任何帮助。
由于这是一个可执行文件,请尝试添加<RuntimeIdentifier>win</RuntimeIdentifier>TargetFramework 属性组。
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifier>win</RuntimeIdentifier> // add this
<Platforms>x86;x64</Platforms>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10701 次 |
| 最近记录: |