UWP/Visual Studio:如何制作不同的构建变体? [英] UWP / Visual Studio: How to make different builds variants?

查看:19
本文介绍了UWP/Visual Studio:如何制作不同的构建变体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 UWP 应用需要具有三种不同的构建变体(风格),可以并行安装:一种用于生产,一种用于测试,一种用于开发.它们显然需要共享相同的代码库,但具有不同的常量,例如后端 URL 和 API 密钥.

I need to have three different build variants (flavors) of my UWP app that can be installed parallel: one for production, one for testing and one for development. They obviously need to share the same code base but have different constants like backend URLs and API keys.

在 Android Studio 中,这可以使用构建变体"来完成,而在 Xcode 中,这可以使用方案"来完成.什么是 Visual Studio 等价物?

In Android Studio this can be done using "build variants" and in Xcode this can be done using "schemes". What's the Visual Studio equivalent of those?

也许使用配置管理器构建配置",如 https://msdn.microsoft.com/en-us/library/kwybya3w.aspx 是要走的路.默认情况下,我有一个 Debug 和一个 Release 配置.将它们重命名为 Production-Debug 和 Production-Release,然后创建 Testing-Debug、Testing-Release、Development-Debug 和 Development-Release 是否正确?我不明白的是:

Maybe "build configurations" using the Configuration Manager as in https://msdn.microsoft.com/en-us/library/kwybya3w.aspx is the way to go. By default I have a Debug and a Release configuration. Would it be correct to rename those to Production-Debug and Production-Release and then create Testing-Debug, Testing-Release, Development-Debug and Development-Release? What I don't understand though:

  1. 这能让我在同一台设备上并行安装生产、测试​​和开发吗?
  2. 我如何知道我在代码中运行的是哪种风格(以获得不同的属性、常量)?

这是关于 UWP 应用,而不是关于网络应用.

This is about UWP apps, not about web apps.

推荐答案

你可以像这样使用条件:

You can just use conditionals like this:

<AppxManifest Include="Manifest.Debug.xml"
              Condition="'$(Configuration)'=='Debug'">
  <SubType>Designer</SubType>
</AppxManifest>
<AppxManifest Include="Package.appxmanifest"
              Condition="'$(Configuration)'=='Release'">
  <SubType>Designer</SubType>
</AppxManifest>

这篇关于UWP/Visual Studio:如何制作不同的构建变体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆