我为 Windows 8.1/Windows Phone 8.1 开发了一个通用应用程序。
此应用程序必须默认推荐给主要客户,但其他客户必须能够通过提供自己的名称、自己的 Assets (图标、闪屏等)和自己的 UI 颜色来对其进行自定义。我正在寻找一个允许我这样做的解决方案。
因此我想创建多个文件“appxmanifest”:
- 默认的“Package.appxmanifest”
- 每个客户一个“Customer1.appxmanifest”,“Customer2.appxmanifest”,...
=> 但是我不知道如何指定一个不同的“appxmanifest”在编译时使用:这可能吗?
此外,UI 颜色在 xaml 文件中定义,该文件使用“MergedDictionaries”与“App.xaml”文件合并。
=> 有办法做到这一点吗?
最佳答案
您可以使用 build configuration 的组合来做到这一点和一个 pre-build事件。
- 为每个客户创建构建配置,并附上他们的名字
- 在您的项目目录中创建一个 prebuild.bat 文件,该文件会将正确客户的文件复制到项目目录中。
@setlocal enableextensions enabledelayedexpansion
@echo off
set buildconfig=%1
set projectdir=%~2
if %buildconfig% == "Customer1" goto CopyCustomerFiles
if %buildconfig% == "Customer2" goto CopyCustomerFiles
goto End
:CopyCustomerFiles
xcopy "%projectdir%\customers\%buildconfig%" "%projectdir%" /I/Y/R/S
goto End
:End
endlocal
- 像这样添加一个预构建事件:
"$(ProjectDir)prebuild.bat""$(ConfigurationName)""$(ProjectDir)"
批处理文件会将客户特定文件夹的全部内容复制到您的项目中,其中可以包括 appxmanifest 和 xaml 文件。 这假设所有客户特定文件都位于 Windows Phone 项目的 customers/[客户名称] 文件夹中。
关于windows-phone - Windows 通用应用程序 "rebranding": one app but multiple packages,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29284329/