Skip to content

Better support for non-standard $(Configuration) names #31918

@jonathanpeppers

Description

@jonathanpeppers

Is your feature request related to a problem? Please describe.

.NET MAUI customers commonly create customer project configuration names, such as ReleaseProd, AdHoc, AppStore, etc.

Visual Studio gives a handy UI for creating configurations and setting properties based on them, and so customers use this to toggle values in their applications such as:

  • Service endpoint URLs: is it Dev or Prod? Using $(DefineConstants) and #if together.
  • iOS signing settings: is it a Release build for the App Store or Development/beta testing

The problem becomes once a custom configuration is made, customers have to somehow know lots of MSBuild properties to set. Starting with:

<!-- User-facing configuration-specific defaults -->
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols Condition=" '$(DebugSymbols)' == '' ">true</DebugSymbols>
<Optimize Condition=" '$(Optimize)' == '' ">false</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<Optimize Condition=" '$(Optimize)' == '' ">true</Optimize>
</PropertyGroup>

At minimum, they would need to know to set $(DebugSymbol) and $(Optimize) appropriately.

Then for mobile, they would also need:

  • For Debug scenarios
    • $(UseInterpreter) set to true for Hot Reload
    • $(EmbedAssembliesIntoApk) set to false for Android "fast deployment" / sideloading
  • For Release scenarios on Android
    • $(PublishTrimmed)
    • $(RunAOTCompilation)
    • $(AndroidPackageFormat) set to aab to create Android "app bundles" for Google Play instead of an .apk
  • The settings required on iOS further complicates things
    • Debug builds need $(PublishTrimmed)
    • Trimmer settings like $(DebuggerSupport) are off for Release mode

There may be several more iOS properties I've left out here.

Describe the solution you'd like

A simple approach would be introduction of new properties like $(IsDebug) and $(IsRelease) where the new code would instead do:

 <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> 
   <IsDebug Condition=" '$(IsDebug)' == '' ">true</IsDebug> 
 </PropertyGroup> 
  <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> 
   <IsRelease Condition=" '$(IsRelease)' == '' ">true</IsRelease> 
 </PropertyGroup> 
 <PropertyGroup Condition=" '$(IsDebug)' == 'true' "> 
   <DebugSymbols Condition=" '$(DebugSymbols)' == '' ">true</DebugSymbols> 
   <Optimize Condition=" '$(Optimize)' == '' ">false</Optimize> 
 </PropertyGroup> 
 <PropertyGroup Condition=" '$(IsRelease)' == 'true' "> 
   <Optimize Condition=" '$(Optimize)' == '' ">true</Optimize> 
 </PropertyGroup> 

Customer projects would do:

<PropertyGroup Condition=" '$(Configuration)' == 'DebugFoo' ">
  <IsDebug>true</IsDebug>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseFoo' ">
  <IsRelease>true</IsRelease>
</PropertyGroup>

And then any defaults defined in optional workloads, etc. are based on these new properties instead of the configuration name directly.

An alternative would be some new MSBuild feature to "inherit" or "extend" configurations. That may just be too much for solving this problem.

Links

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions