Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UWP / Visual Studio: How to make different builds variants?

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.

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?

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. Will that allow me to install Production, Testing and Development parallel on the same device?
  2. How do I know which flavor I'm running in code (in order to get different properties, constants)?

EDIT: This is about UWP apps, not about web apps.

like image 633
user1195883 Avatar asked Dec 02 '16 08:12

user1195883


People also ask

How do I get build options in Visual Studio?

If you want to build multiple configurations and platforms in one action, you can use the Build > Batch Build option in Visual Studio. To access this feature, press Ctrl+Q to open the search box, and enter Batch build .


2 Answers

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>
like image 95
LOST Avatar answered Sep 19 '22 07:09

LOST


Double click on Package.appxmanifest file in your project.

Select Packaging label and enter different Package names for different cases.

Store each of variants.

Your PC gonna think these are different UWP apps.

like image 23
Jet Chopper Avatar answered Sep 19 '22 07:09

Jet Chopper