我已经在这里遇到了这样的错误:Errors with dotnet publish,但是我只需要创建一个全新的解决方案,就可以悄悄地离开它。嗯,这不再是一种选择了,因为我现在正在做一个真正的项目。
经过我在这些错误中花费的很多天,我能够编译一些项目并在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向我抛出了这个错误:
error NETSDK1032: RuntimeIdentifier平台'ios-arm64‘和PlatformTarget 'x64’必须兼容。
查看binlog,我看到了以下内容:
虽然该项目的配置显示如下:
据推测,PlatformTarget设置为"x64",但事实并非如此。至少没有根据项目设置。除非有别的地方来配置它。
它尝试将其更改为ARM64并返回到任何CPU,我尝试在XML中为一个或全部PropertyGroups指定,并且尝试在命令行中指定它,如下所示:
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>
发布于 2022-06-05 13:47:14
我想出来了!是*.csproj.user文件!
这就是我删除之前的样子。
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugFramework>net6.0-windows10.0.19041.0</ActiveDebugFramework>
<IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
<ActiveDebugProfile>Windows Machine</ActiveDebugProfile>
<SelectedPlatformGroup>Simulator</SelectedPlatformGroup>
<DefaultDevice>iPhone 13 Pro Max iOS 15.5</DefaultDevice>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetPlatformIdentifier)'=='iOS'">
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-android|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
<ItemGroup>
<MauiXaml Update="View\ActivityDetailPage.xaml">
<SubType>Designer</SubType>
</MauiXaml>
<MauiXaml Update="View\SettingsPage.xaml">
<SubType>Designer</SubType>
</MauiXaml>
</ItemGroup>
</Project>
这就是解决方案文件第一次打开后的样子。
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
这是怎么
<PlatformTarget>x64</PlatformTarget>
进去了,我不知道。我不能复制它。以及为什么这会压倒项目或命令行参数的实际设置。
https://stackoverflow.com/questions/72502924
复制相似问题