我使用这些资源来学习如何发布 MAUI 应用程序:
\nhttps://learn.microsoft.com/en-us/dotnet/maui/ios/deployment/overview
\nhttps://github.com/dotnet/maui/issues/4397
\nhttps://github.com/dotnet/sdk/issues/21877
\n基于这些,我尝试了不同的变体来发布,但它们都不起作用:
\ndotnet publish -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 \nRun Code Online (Sandbox Code Playgroud)\n\n\n错误:运行时标识符“ios-arm64”无效。
\n
dotnet publish -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 --no-restore\nRun Code Online (Sandbox Code Playgroud)\n\n\n错误 NETSDK1032:RuntimeIdentifier 平台“ios-arm64”和\nPlatformTarget“x64”必须兼容。
\n
dotnet build -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 /p:BuildIpa=true\nRun Code Online (Sandbox Code Playgroud)\n\n\n错误:运行时标识符“ios-arm64”无效。
\n
dotnet build -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 /p:BuildIpa=true --no-restore\nRun Code Online (Sandbox Code Playgroud)\n\n\n错误 NETSDK1032:RuntimeIdentifier 平台“ios-arm64”和\nPlatformTarget“x64”必须兼容。
\n
更新
\n环境:
\nWindows 10 家庭版 - 21H2
\nVS 2022 版本 17.3.0 预览版 1.1
更新2
\n根据答案,我现在有了这个 csproj 文件:
我已经在这里遇到了这个错误:Errors with dotnetpublish但我能够通过创建一个全新的解决方案来避开它。好吧,这不再是一个选择,因为我现在正在做一个真正的项目。
经过我在这些错误中度过的许多天,我能够编译一些项目并将它们分发到 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”必须兼容。
据说 PlatformTarget 设置为“x64”,但事实并非如此。至少不是根据项目设置。除非有别的地方可以配置。
它尝试将其更改为 ARM64,然后返回到任何 CPU,我尝试在 XML 中指定一个或所有 PropertyGroup,并尝试在命令行中指定它,如下所示:
dotnet publish -f:net6.0-ios -c:Release /p:Platform="Any CPU"
Run Code Online (Sandbox Code Playgroud)
我也变了
<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
Run Code Online (Sandbox Code Playgroud)
到
<PropertyGroup Condition="$(TargetFramework.Contains('-ios'))>
Run Code Online (Sandbox Code Playgroud)
然后是这个:
dotnet publish -f:net6.0-ios -c:Debug /p:Platform="Any CPU"
Run Code Online (Sandbox Code Playgroud)
这些都没有任何效果。我缺少什么?
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks …Run Code Online (Sandbox Code Playgroud) 我正在学习了解 .NET MAUI 的 XAML 中的绑定机制如何工作。我假设这对于所有 XAML 项目、WPF、MAUI 等都是相同的。
\n最后是整个 XAML。
\n这个 XAML 工作正常:
\n<Button WidthRequest="150" Text="Add Activity" \n Command="{Binding AddActivityEntityCommand}"\n IsEnabled="{Binding IsNotBusy}"\n Grid.Row="2"\n Margin="8"/>\nRun Code Online (Sandbox Code Playgroud)\n这是因为 Button 是 ContentPage 的一部分,它被x:DataType设置为MainPageViewModel,这是命令所在的位置吗?
Binding 设置为AddActivityEntityCommand,而实际方法签名为\n async Task AddActivityEntityAsync()。这是如何解决的?因为它显然与名称不匹配,但它有效。其工作/被认可的方法签名要求是什么?
另一方面,这并不像开箱即用那么简单:
\n<Label HorizontalOptions="End" TextColor="Red" Padding="0,0,10,0" Text="" \n IsVisible="{Binding IsSynchronized}">\n <Label.GestureRecognizers>\n <TapGestureRecognizer \n Command="{Binding Source={x:Type viewmodel:MainPageViewModel},\n Path=DeleteActivityCommand}" />\n </Label.GestureRecognizers>\n </Label>\nRun Code Online (Sandbox Code Playgroud)\nCommand="{Binding DeleteActivityCommand}不起作用,因为<DataTemplate x:DataType="model:ActivityEntity"> …