我在这里已经遇到了这个错误:dotnet 发布错误但我只需创建一个全新的解决方案就可以摆脱它。好吧,这不再是一个选择,因为我现在正在做一个真正的项目。
经过我在这些错误中度过的许多天,我能够编译一些项目并将它们分发到 iPhone 上。只是,在创建一个新的解决方案的过程中,稍微进行一些工作,突然发生了这个特定的错误,我不知道如何解决它。也许有人有洞察力。
该项目在远程 Mac 上的模拟器和 Windows 上作为 Windows 应用程序完美运行。
环境:
Windows 10 家庭版,21H2
VS 2022 版本 17.3.0 预览版 1.1
这是我到目前为止所做的:
dotnet publish -f:net6.0-ios -c:Release /bl:msbuild.binlog
这篇文章末尾的 XML 向我抛出了这个错误:
错误 NETSDK1032:RuntimeIdentifier 平台“ios-arm64”和
PlatformTarget“x64”必须兼容。
Looking into the binlog I see this:
While the configuration of the project shows this:
据说 PlatformTarget 设置为“x64”,但事实并非如此。至少不是根据项目设置。除非有别的地方可以配置。
它尝试将其更改为 ARM64,然后返回到任何 CPU,我尝试在 XML 中指定一个或所有 PropertyGroup,并尝试在命令行中指定它,如下所示:
dotnet publish -f:net6.0-ios -c:Release /p:Platform="Any CPU"
我也变了
<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
to
<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>