.net core 错误NETSDK1032:运行时标识符平台';win-x86';以及平台目标';x64和x27;必须兼容
我的解决办法是:.net core 错误NETSDK1032:运行时标识符平台';win-x86';以及平台目标';x64和x27;必须兼容,.net-core,.net Core,我的解决办法是: 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", "Cor
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>
正如您所见,它或多或少是为.Net Core 3.1创建的新控制台应用程序。我所做的唯一修改是用x86和x64替换“任何CPU”体系结构。它可以使用VS成功构建,用于发布/调试和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\sdk\Microsoft.NET.sdk\targets\Microsoft.NET.RuntimeIdentifierReference.targets(151,5):错误NETSDK1032:运行时标识符平台“win-x86”和平台目标“x64”必须兼容
这是重现此问题的最小解决方案,但我有一个更大且配置相同的解决方案,其失败方式稍有不同:
C:\Program Files\dotnet\sdk\3.1.100\sdk\Microsoft.NET.sdk\targets\Microsoft.NET.RuntimeIdentifierReference.targets(151,5):错误NETSDK1032:运行时标识符平台“win-x64”和平台目标“x86”必须兼容**
它对前两个命令失败,对第二对命令有效。这可能是因为较大的解决方案在本节中的顺序不同:
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
我正在使用Win 10 Prof机器(Intel的I7),在最近的一次VS更新中安装了VS2019和.Net Core 3.1 SDK(64位)。系统和所有安装的软件都是最新的
我完全不知道这里出了什么问题,也不知道我做错了什么
我将非常感谢您的帮助。由于这是一个可执行文件,请尝试在TargetFramework属性组中添加
win
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifier>win</RuntimeIdentifier> // add this
<Platforms>x86;x64</Platforms>
</PropertyGroup>
Exe
netcoreapp3.1
win//添加此
x86;x64
向节点“RuntimeIdentifier”添加值是没有用的。我来问一下,您是如何加载命令提示符的?您的任务栏或图标是否使用了批处理文件?它用了吗
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat
如果是,您可能使用由该批文件创建的C++命令环境运行“dotnet构建”。
回答:不要使用VC++命令环境运行ASP.NET Core CLI。相反,请使用为ASP.NET核心CLI命令正确配置的命令环境。我怎么知道的?如果查看vcvarsall.bat,您将在批处理文件的第71到75行中看到以下内容:@REM This temporary environment variable is used to control setting of VC++
@REM command prompt-specific environment variables that should not be set
@REM by the VS Developer Command prompt (specifically vsdevcmd\ext\vcvars.bat).
@REM The known case this effects is the Platform environment variable, which
@REM will override platform target for .NET builds.
取而代之的是,使用VS2019附带的一个,就像在Windows的“开始”菜单中一样。命令窗口应类似于以下内容:
如下图所示,我编译了一个WASM,只要您拥有正确的MS构建环境(在VS 2019命令环境中设置正确),它就可以工作:
我的错误消息不同,但我的修复可能适用。错误是:
The RuntimeIdentifier platform 'browser-wasm' and the PlatformTarget 'x64' must be compatible.
该项目是Blazor WebAssembly项目。csproj文件中包含以下内容:
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
net5.0
x64
我用anycpu替换了x64,这是我在用浏览器wasm替换x64后收到的另一条错误消息。哈
在修复之前,解决方案资源管理器中的所有引用/依赖项上都有警告三角形。标记的意思是,我不知道DxDataGrid是什么。您需要@using语句吗。所有这些都在修复后消失。对于VS 2019 CLI,命令窗口将正确执行
dotnet run
和dotnet build
功能。第一次使用后,您还可以从窗口看到一个漂亮的“欢迎”。看起来是这样的:欢迎使用.NET5.0代码>感谢Scott Hanselman的独立注入,以及Microsoft为我们提供的代码选项!斯科特,保重你自己,希望你每次都能正确地和情妇争论!
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>