1.MAUI Android可以正常显示
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->
|
||||
|
||||
<OutputType>Exe</OutputType>
|
||||
<AndroidApplication>true</AndroidApplication>
|
||||
<RootNamespace>Hua.Todo.Maui</RootNamespace>
|
||||
<UseMaui>true</UseMaui>
|
||||
<SingleProject>true</SingleProject>
|
||||
@@ -28,7 +29,7 @@
|
||||
<ApplicationTitle>代办</ApplicationTitle>
|
||||
|
||||
<!-- App Identifier -->
|
||||
<ApplicationId>com.companyname.Hua.Todo.maui</ApplicationId>
|
||||
<ApplicationId>com.hua.todo</ApplicationId>
|
||||
|
||||
<!-- Versions -->
|
||||
<!-- Unified in Directory.Build.props -->
|
||||
@@ -70,16 +71,12 @@
|
||||
<SkipWebBuild>true</SkipWebBuild>
|
||||
<AndroidPackageFormat>apk</AndroidPackageFormat>
|
||||
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi>
|
||||
<!-- 默认启用 Fast Deployment,加速日常 C#/XAML 调试。 -->
|
||||
<AndroidUseSharedRuntime Condition="'$(ForceFullAndroidDeploy)' != 'true'">True</AndroidUseSharedRuntime>
|
||||
<AndroidEnableFastDeployment Condition="'$(ForceFullAndroidDeploy)' != 'true'">True</AndroidEnableFastDeployment>
|
||||
<AndroidFastDeploymentType Condition="'$(ForceFullAndroidDeploy)' != 'true'">Assemblies</AndroidFastDeploymentType>
|
||||
<EmbedAssembliesIntoApk Condition="'$(ForceFullAndroidDeploy)' != 'true'">False</EmbedAssembliesIntoApk>
|
||||
<!-- 需要验证 Android 资源变更时,传入 -p:ForceFullAndroidDeploy=true。 -->
|
||||
<AndroidUseSharedRuntime Condition="'$(ForceFullAndroidDeploy)' == 'true'">False</AndroidUseSharedRuntime>
|
||||
<AndroidEnableFastDeployment Condition="'$(ForceFullAndroidDeploy)' == 'true'">False</AndroidEnableFastDeployment>
|
||||
<EmbedAssembliesIntoApk Condition="'$(ForceFullAndroidDeploy)' == 'true'">True</EmbedAssembliesIntoApk>
|
||||
<AndroidSupportedAbis>x86_64</AndroidSupportedAbis>
|
||||
<!-- .NET 10 Preview 环境下,Shared Runtime 和 Fast Deployment 往往会导致 AndroidX 依赖解析异常 (NoClassDefFoundError)。
|
||||
为了稳定性,默认启用完整部署模式 (EmbedAssembliesIntoApk=True)。 -->
|
||||
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
|
||||
<AndroidEnableFastDeployment>False</AndroidEnableFastDeployment>
|
||||
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
|
||||
<RuntimeIdentifiers>android-x64</RuntimeIdentifiers>
|
||||
<UseAppHost>false</UseAppHost>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -166,7 +163,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Build web assets into MAUI `wwwroot` so both Windows publish and Android packaging can reuse the same folder. -->
|
||||
<Target Name="BuildTodoWeb" BeforeTargets="UpdateAndroidAssets;BeforeBuild" Condition="'$(SkipWebBuild)' != 'true' And Exists('$(TodoWebDir)') And ('$(ForceWebBuild)' == 'true' Or !Exists('$(MSBuildProjectDirectory)\wwwroot\index.html'))">
|
||||
<Target Name="BuildTodoWeb" BeforeTargets="UpdateAndroidAssets;BeforeBuild" Condition="Exists('$(TodoWebDir)') And (!Exists('$(MSBuildProjectDirectory)\wwwroot\index.html') Or '$(SkipWebBuild)' != 'true' Or '$(ForceWebBuild)' == 'true')">
|
||||
<Exec Command="npm ci" WorkingDirectory="$(TodoWebDir)" Condition="Exists('$(TodoWebDir)\package-lock.json') And !Exists('$(TodoWebDir)\node_modules')" />
|
||||
<Exec Command="npm install" WorkingDirectory="$(TodoWebDir)" Condition="!Exists('$(TodoWebDir)\package-lock.json') And !Exists('$(TodoWebDir)\node_modules')" />
|
||||
<Exec Command="npm run build:maui" WorkingDirectory="$(TodoWebDir)" />
|
||||
@@ -184,21 +181,33 @@
|
||||
|
||||
<ItemGroup>
|
||||
<MauiAsset Include="@(_TodoWebDistFiles)">
|
||||
<LogicalName>wwwroot/%(RecursiveDir)%(Filename)%(Extension)</LogicalName>
|
||||
<LogicalName>$([System.String]::Copy('wwwroot/%(RecursiveDir)%(Filename)%(Extension)').Replace('\', '/'))</LogicalName>
|
||||
</MauiAsset>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<Target Name="IncludeMauiWwwrootAsMauiAssets" BeforeTargets="ProcessMauiAssets" DependsOnTargets="BuildTodoWeb" Condition="'$(TargetFramework)' == 'net10.0-android' And Exists('$(MSBuildProjectDirectory)\wwwroot\index.html')">
|
||||
<Target Name="IncludeMauiWwwrootAsMauiAssets" BeforeTargets="BeforeBuild;ProcessMauiAssets" DependsOnTargets="BuildTodoWeb" Condition="'$(TargetFramework)' == 'net10.0-android'">
|
||||
<ItemGroup>
|
||||
<_MauiWwwrootFiles Include="$(MSBuildProjectDirectory)\wwwroot\**\*" />
|
||||
<!-- 确保包含所有 wwwroot 下的文件,包括子目录。 -->
|
||||
<_MauiWwwrootFiles Include="wwwroot\**\*" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- 显式设置 Link 和 LogicalName。
|
||||
在 Android 上,LogicalName 决定了 AssetManager.Open() 的路径。 -->
|
||||
<MauiAsset Include="@(_MauiWwwrootFiles)">
|
||||
<LogicalName>wwwroot/%(RecursiveDir)%(Filename)%(Extension)</LogicalName>
|
||||
<Link>wwwroot\%(RecursiveDir)%(Filename)%(Extension)</Link>
|
||||
<LogicalName>$([System.String]::Copy('wwwroot/%(RecursiveDir)%(Filename)%(Extension)').Replace('\', '/'))</LogicalName>
|
||||
</MauiAsset>
|
||||
|
||||
<!-- 同时尝试在根目录也放一份 index.html,增加容错。 -->
|
||||
<MauiAsset Include="wwwroot\index.html" Condition="Exists('wwwroot\index.html')">
|
||||
<Link>index.html</Link>
|
||||
<LogicalName>index.html</LogicalName>
|
||||
</MauiAsset>
|
||||
</ItemGroup>
|
||||
|
||||
<Message Importance="high" Text="[Build] Included $(_MauiWwwrootFiles->Count()) assets from wwwroot into MauiAsset (with wwwroot/ prefix and root fallback)" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user