错误NetSDK1032:Runtime Indentifier平台' ios-Arm64'和PlatformTarget' x64'必须兼容
我已经在这里遇到了这个错误: dotnet publish publish 但是我能够潜行通过创建一个全新的解决方案来远离它。好吧,这已经不再是一个选择,因为我现在正在研究一个真正的项目。
在我花了很多天的时间里,我能够编译一些项目并在iPhone上分发它们。只是,从创建新的解决方案,稍微努力的某个路径中的某个地方,出现了这个特定的错误,我不知道如何解决它。也许有人有洞察力。
该项目以Windows应用程序在远程Mac和Windows上的模拟器中完美运行。
环境:
Windows 10 Home,21H2
vs 2022版本17.3.0预览1.1
这是我到目前为止所做的:
dotnet Publish -f:net6.0-ios -c:preasion /bly:msbuild.binlog
< /code < /code> the the the End这篇文章给我带来了这个错误:
错误netsdk1032:RuntimeIdentifier平台'ios-arm64'和 PlatformTarget'X64'必须兼容。
据说平台标准设置为“ x64”,但事实并非如此。至少不是根据项目设置。除非还有另一个可以配置它。
它尝试将其更改为ARM64,然后返回到任何CPU,我尝试在XML中为一个或所有属性组指定,然后尝试在命令行中指定它:
dotnet publish -f:net6.0-ios -c:Release /p:Platform="Any CPU"
我也更改
<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
为
<PropertyGroup Condition="$(TargetFramework.Contains('-ios'))>
,然后将其
dotnet publish -f:net6.0-ios -c:Debug /p:Platform="Any CPU"
更改 为:有任何效果。 我想念什么?
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>OnesieMobile</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>OnesieMobile</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.maui.app</ApplicationId>
<ApplicationIdGuid>447A62C6-2841-41D6-B9AE-444E6E1A908B</ApplicationIdGuid>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
<RuntimeIdentifiers>ios-arm64</RuntimeIdentifiers>
<CodesignProvision>Maui Provisioning</CodesignProvision>
<CodesignKey>Apple Distribution: My Name (XXXX)</CodesignKey>
<ArchiveOnBuild>true</ArchiveOnBuild>
<TcpPort>58181</TcpPort>
<ServerAddress>xxxxx</ServerAddress>
<ServerUser>xxxx</ServerUser>
<ServerPassword>xxxx</ServerPassword>
<_DotNetRootRemoteDirectory>/Users/xxxx/Library/Caches/Xamarin/XMA/SDKs/dotnet/</_DotNetRootRemoteDirectory>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="1.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
</ItemGroup>
<ItemGroup>
<Compile Update="View\ActivityDetailPage.xaml.cs">
<DependentUpon>ActivityDetailPage.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<MauiXaml Update="View\ActivityDetailPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="View\SettingsPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
</Project>
I've had this error already over here: Errors with dotnet publish but I was able to sneak away from it, by just creating a brand new solution. Well, that's not an option anymore, because I am working on a real project now.
Through all the many days I have spent with these errors, I was able to compile some of the projects and distribute them on an IPhone. It's just, that somewhere in that path from creating a fresh solution, working on it a little bit, suddendly this specific error occurs, and I don't know how to solve it. Maybe someone has an insight.
The project runs perfectly in the simulator on the remote Mac and on the Windows as Windows app.
Environment:
Windows 10 Home, 21H2
VS 2022 Version 17.3.0 Preview 1.1
Here is what I have done so far:
dotnet publish -f:net6.0-ios -c:Release /bl:msbuild.binlog
with the XML at the end of this post throws this error at me:
error NETSDK1032: The RuntimeIdentifier platform 'ios-arm64' and the
PlatformTarget 'x64' must be compatible.
Looking into the binlog I see this:
While the configuration of the project shows this:
Supposedly the PlatformTarget is set to "x64", But it's not. At least not according to the project settings. Unless there is another place to configure it.
It tried changing it to ARM64 and back to Any CPU, I tried specifying in the XML for either one or all PropertyGroups, and I tried specifying it in the command line like this:
dotnet publish -f:net6.0-ios -c:Release /p:Platform="Any CPU"
I've also changed
<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
to
<PropertyGroup Condition="$(TargetFramework.Contains('-ios'))>
and then this:
dotnet publish -f:net6.0-ios -c:Debug /p:Platform="Any CPU"
None of these have any effect whatsoever. What am I missing?
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>OnesieMobile</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>OnesieMobile</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.maui.app</ApplicationId>
<ApplicationIdGuid>447A62C6-2841-41D6-B9AE-444E6E1A908B</ApplicationIdGuid>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
<RuntimeIdentifiers>ios-arm64</RuntimeIdentifiers>
<CodesignProvision>Maui Provisioning</CodesignProvision>
<CodesignKey>Apple Distribution: My Name (XXXX)</CodesignKey>
<ArchiveOnBuild>true</ArchiveOnBuild>
<TcpPort>58181</TcpPort>
<ServerAddress>xxxxx</ServerAddress>
<ServerUser>xxxx</ServerUser>
<ServerPassword>xxxx</ServerPassword>
<_DotNetRootRemoteDirectory>/Users/xxxx/Library/Caches/Xamarin/XMA/SDKs/dotnet/</_DotNetRootRemoteDirectory>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="1.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
</ItemGroup>
<ItemGroup>
<Compile Update="View\ActivityDetailPage.xaml.cs">
<DependentUpon>ActivityDetailPage.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<MauiXaml Update="View\ActivityDetailPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="View\SettingsPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
</Project>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我遇到了同样的问题,我将使用您的答案,但首先偶然发现了我们遇到这个问题的原因。我也有那个条目,我认为这是因为我刚刚在连接的Mac上使用iOS模拟器完成了调试。一旦我更改发布并在下拉列表中制作了目标“远程设备”,该标签就会消失,我可以发布。
I had the same problem and I was going to use your answer but stumbled on the reason we had that problem in the first place. I also had that entry and I think it was because I just finished debugging with an iOS Simulator on a connected Mac. Once I changed to Release and made target "Remote Device" in the dropdown, that tag disappears and I can publish.
在vs 17.12.3中,此消息仍然偶尔出现(有些事情显然从未解决)。事实证明,CSUSER文件非常严重,一个快速修复是将目标更改为另一个平台然后返回。
我发现在真实的iOS设备和iOS模拟器之间进行操作会导致问题。将其更改为两者之间的Windows机器(无需实际编译和运行,只是中间步骤似乎都起作用)。
This message still comes up occassionally in VS 17.12.3 (some things never get fixed apparently). Turns out it writes that csuser file badly and a quick fix is to change the target to another platform and back again.
I find going between a real iOS device and an iOS simulator causes the issue. Changing it to Windows machine in between fixes it (no need to actually compile and run, just the intermediate step seems to work).
我弄清楚了!这是 *.csproj.user文件!!!
这就是我删除它之前的样子。
这就是解决方案文件的第一个打开后的样子。
这是怎么
我不知道 回到那里的。我不能复制它。以及为什么这要压倒项目或命令行参数的实际设置。
I figured it out! it was the *.csproj.user file!!!
This is what it looked like before I deleted it.
And this is what it looks like after the first opening of the solution file.
How this
got in there, I don't know. I can't reproduce it. And why this is overpowering the actual settings of the project or the command line arguments.