Xamarin:针对不同构建配置的不同appxmanifest文件

时间:2017-12-14 08:29:42

标签: xamarin xamarin.forms uwp xamarin.uwp

我想为一些构建配置使用不同的Package.appxmanifest文件。我不能在我的Xamarin-UWP项目中包含多个appxmanifest文件。 像Android这样的想法也不起作用:

为多个AndroidManifest文件工作:

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-CH|AnyCPU'">
…
<AndroidManifest>Properties\AndroidManifestCH.xml</AndroidManifest>
</PropertyGroup>

我如何为UWP实现这个目标?

1 个答案:

答案 0 :(得分:1)

And ideas like doing it like Android also doesn't work

According to App package manifest, Every app package must include one package manifest. If you create a new appxmanifest file in the uwp, it will throw error like the follow.

The project contains 2 items that represent the app manifest: Package.appxmanifest, Test.appxmanifest. The project can contain only one app manifest

If you do want to use different Package.appxmanifest files for some build configurations. you could edit FileGuidTest.csproj manually.

Right Click Project-> Unload Project-> Re-Right Click Project-> Edit Project.csproj file.

<ItemGroup>
  <AppxManifest Include="Package.appxmanifest">
    <SubType>Designer</SubType>
  </AppxManifest>
  <AppxManifest Include="app.appxmanifest">
    <SubType>Designer</SubType>
  </AppxManifest>
  <None Include="FileGuidTest_TemporaryKey.pfx" />
  <AppxManifest Include="Test.appxmanifest">
    <SubType>Designer</SubType>
  </AppxManifest>
</ItemGroup>

Find out the above ItemGroup node and reserve only one AppxManifest. And then modify the follow PropertyGroup node.

<PropertyGroup>
  <ApplicationManifest>Package.appxmanifest</ApplicationManifest>
</PropertyGroup>