{"id":31389,"date":"2017-06-13T13:24:35","date_gmt":"2017-06-13T20:24:35","guid":{"rendered":"https:\/\/blog.xamarin.com\/?p=31389"},"modified":"2019-04-04T08:30:53","modified_gmt":"2019-04-04T15:30:53","slug":"demystifying-build-configurations","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/xamarin\/demystifying-build-configurations\/","title":{"rendered":"Demystifying Build Configurations"},"content":{"rendered":"<p>\t\t\t\tMost developers are familiar with the <code>Debug<\/code> and <code>Release<\/code> configurations in most solution templates in use. It seems obvious to use the <code>Debug<\/code> configuration when building your project for debugging and to use the <code>Release<\/code> configuration when building your project for release. What may be less clear, though, is what&#8217;s actually happening when you switch configurations, or how to add your own custom configurations. Today, we&#8217;re going to dive a little deeper into the world of build configurations to see how they can greatly improve your build times and productivity.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/Screen-Shot-2017-06-01-at-15.33.52.png\" alt=\"\" width=\"800\" height=\"90\" class=\"aligncenter size-full wp-image-31867\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/vsconfigs.png\" alt=\"\" width=\"800\" height=\"115\" class=\"aligncenter size-full wp-image-31868\" \/><\/p>\n<h2>What Are Configurations?<\/h2>\n<p>Simply stated, configurations are a set of project properties. In the default <code>Debug<\/code> configuration, for instance, debugging will be enabled, while in a <code>Release<\/code> configuration it will not be. You can set what linker options to use in each configuration, what architectures (CPUs) to build for, etc. You can also further define platforms so that you can have separate project settings depending on whether you are building for a device or emulator. In other words, you can set separate project settings for each <code>Configuration|Platform<\/code> combination that you have available in your project.<\/p>\n<h2>How Can I Edit a Configuration?<\/h2>\n<p>To illustrate how to edit, and later add, a configuration we&#8217;ll start with a template Android project:<\/p>\n<p><em>In VS for Mac<\/em> create a new &#8220;Android App&#8221;: New Project &gt; Android &gt; App &gt; Android App.<br \/>\n<em>In VS for Windows<\/em> create a &#8220;Single-View App (Android)&#8221;: Create new project&#8230; &gt; Android &gt; Single-View App (Android).<\/p>\n<p>The template creates a simple Android app with a button that counts clicks. It has two configurations set up by default, <code>Debug<\/code> and <code>Release<\/code>, and one platform, <code>AnyCPU<\/code>. These are simply names that don&#8217;t have any inherent meaning, except being reflective of when the configuration should be used. We&#8217;re going to add two new configurations named <code>DebugDevice<\/code> and <code>DebugEmulator<\/code> later on. These will allow us to quickly set the desired project options\/properties when debugging to a device (ARM) or an emulator (x86). Each will only build for the architectures needed for a device or an emulator, reducing build time during development.<\/p>\n<p>First, let&#8217;s see what&#8217;s different between the two default <code>Debug<\/code> and <code>Release<\/code> configurations. To do so, open the project properties by right-clicking on the project in the solution explorer and selecting &#8220;Options&#8221; (VS for Mac) or &#8220;Properties&#8221; (VS for Windows). Once the project options\/properties are open, you&#8217;ll see configuration and platform fields towards the top with drop-down lists to select which configuration and platform you want to see the property settings for.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/projectoptions1.png\" alt=\"Project Options\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/VSProjProps.png\" alt=\"Project Properties\" width=\"800\" class=\"aligncenter size-full\" \/><\/p>\n<p>The drop-down may not be there (VS for Mac) or disabled (VS for Windows), which means that the settings on the settings page you have selected are global, i.e. they will apply to all configurations and platforms. You can see this for the Build &gt; General settings page in VS for Mac and in the Application settings page in VS for Windows.<\/p>\n<p>Most of the differences in the project settings for the default <code>Debug<\/code> and <code>Release<\/code> configurations are in the Android Build \/ Android Options settings page shown above. Open the project options\/properties and select the Android Build (VS for Mac) \/ Android Options (VS for Windows) on the left. Make sure <code>Debug<\/code> is selected at the top in the configuration drop down. Note that the &#8220;Use Shared Mono Runtime&#8221; on VS for Mac or &#8220;Use Shared Runtime&#8221; in VS for Windows is selected, as well as the &#8220;Fast Assembly Deployment&#8221; (VS for Mac) \/ &#8220;Use Fast Deployment&#8221; (VS for Windows) option.<\/p>\n<p>These are great options when you are debugging as they will decrease build and deploy times when developing an app, but they are not at all good for building a release version as it is unlikely that an end user will have a shared mono runtime installed on their Android devices so the app would fail to run at all since there would be no runtime. For <code>Release<\/code> builds you would want to disable that option. If you now select <code>Release<\/code> in the configuration drop-down at the top, you will see that the default <code>Release<\/code> configuration has those options disabled.<\/p>\n<p>You can check the Linker behaviour of the respective configurations:<\/p>\n<p><em>In VS for Mac:<\/em> In the Android Build page select the &#8220;Linker&#8221; tab. You will see the &#8220;Linking Behaviour&#8221; is set to &#8220;Don&#8217;t Link&#8221; for <code>Debug<\/code> configuration and &#8220;Link SDK assemblies only&#8221; for <code>Release<\/code> configuration.\n<em>In VS for Windows:<\/em> In the Android Options page scroll to the &#8220;Linker Properties&#8221; section. You will see the &#8220;Linking&#8221; option is set to &#8220;None&#8221; for <code>Debug<\/code> configuration and &#8220;SDK assemblies only&#8221; for <code>Release<\/code> configuration.<\/p>\n<p>These default options allow for faster build during debugging and a smaller app bundle for your release build.<\/p>\n<p>The &#8220;Advanced&#8221; tab (Mac)\/button (Windows) allows you to set which CPUs (ABIs) to build for when building for Debug or Release. You will note that by default the Debug configuration builds for all possible CPUs. Every CPU you build for will take time so it might be nice to streamline this so we are only building for the CPU we will be running the app on. If we are only testing on an x86 emulator, then we can only build for x86 and deselect the other ABIs that are not needed. Go ahead and deselect all but x86 using the Advanced tab\/button.<\/p>\n<p>Congratulations, you have now just edited a configuration. Editing a configuration is as simple as opening the Project Options\/Properties, selecting the configuration you want to change settings for, and changing those settings.<\/p>\n<h2>How Can I Add a Configuration?<\/h2>\n<p>Wouldn&#8217;t it be nice if you could easily choose which architectures to build for during debugging simply by selecting a configuration? If debugging to a device I choose one configuration, <code>DebugDevice<\/code>, and for building to an emulator I choose <code>DebugEmulator<\/code>. Let&#8217;s get that set up.<\/p>\n<h3>Visual Studio for Mac:<\/h3>\n<p>To add a configuration in Visual Studio for Mac:<\/p>\n<ol>\n<li>Open the Solution Options by double clicking on the solution in the solution explorer.<\/li>\n<li>Select Build &gt; Configurations on the left (<em>not<\/em> Run &gt; Configurations).<br \/>\n      <img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/SolutionConfigurations.png\" alt=\"\" class=\"alignnone size-full wp-image-31437\" \/><\/li>\n<li>Since we want a variant of the <code>Debug<\/code> configuration, in the configuration list select <code>Debug<\/code> and click &#8220;Copy&#8221;. This will copy the current <code>Debug<\/code> settings to your new configuration.<\/li>\n<li>Enter the name for this configuration, i.e. <code>DebugDevice<\/code>.<\/li>\n<li>Keep the default Any CPU for the Platform.<\/li>\n<li>Click &#8220;OK&#8221;.<\/li>\n<li>Repeat steps 4-8 for the <code>DebugEmulator<\/code> configuration.<\/li>\n<\/ol>\n<h3>Visual Studio (Windows):<\/h3>\n<p>To add a configuration in Visual Studio (Windows):<\/p>\n<ol>\n<li>Open the Configuration Manager with the Build &gt; Configuration Manager menu.<\/li>\n<li>Click on the Active Solution Configuration drop down and select &#8220;New&#8221;.<br \/>&lt;img src=&quot;https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/NewConfigurationVS.png&quot; alt=&quot;&quot; class=&quot;alignnone size-full wp-image-31444&quot; \/<\/li>\n<li>Enter <code>DebugDevice<\/code> for the Name field.<\/li>\n<li>Select <code>Debug<\/code> in the &#8220;Copy settings from&#8221; drop down list.<\/li>\n<li>Make sure the &#8220;Create new project configurations&#8221; option is checked.<br \/><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/AddConfigurationVS.png\" alt=\"\" class=\"alignnone size-full wp-image-31446\" \/><\/li>\n<li>Click OK.<\/li>\n<li>Repeat steps 2 &#8211; 6 using <code>DebugEmulator<\/code> for the Name field.<\/li>\n<\/ol>\n<p>Now you will see four configurations in the list, Debug, DebugDevice, DebugEmulator, and Release.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/NewConfigurationsXS.png\" alt=\"\" class=\"alignnone size-medium wp-image-31449\" \/>\n<img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/NewConfigurationsVS.png\" alt=\"\" class=\"alignnone size-full wp-image-31448\" \/><\/p>\n<p>Now you just have to open the Android project options and make the desired changes to these two new configurations:<\/p>\n<ol>\n<li>Open the Android project options.<\/li>\n<li>Select the Android Build (Mac) \/ Android Options (Windows) &gt; Advanced tab.<\/li>\n<li>Select <code>DebugDevice<\/code> from the Configuration drop down.<\/li>\n<li>Uncheck all of the Supported ABIs <strong>except<\/strong> armeabi-v7a.<\/li>\n<li>Select <code>DebugEmulator<\/code> from the Configuration drop down.<\/li>\n<li>Uncheck all of the Supported ABIs <strong>except<\/strong> x86.<\/li>\n<\/ol>\n<p>You can now select <code>DebugDevice<\/code> whenever you want to debug using an actual Android device, and you can select <code>DebugEmulator<\/code> whenever you want to debug to an x86 emulator. Your debug builds will be faster since you are only building for the one needed architecture.<\/p>\n<p>Congratulations, you have now added two configurations and set them up for specific debugging scenarios.<\/p>\n<h2>How Can I Add a Platform?<\/h2>\n<p>What we did above works, but it may be better to define platforms instead of configurations to switch between building for device or emulator. You will notice this is done by default for iOS projects. There are two platforms defined for iOS projects, iPhone and iPhoneSimulator. We could do the same for Android if we like. For this exercise, start with a new Xamarin Forms project, PCL or Shared type does not matter for this exercise.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/NewFormsAppVS.png\" alt=\"\" class=\"alignnone size-medium wp-image-31453\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/NewFormsAppXS.png\" alt=\"\" class=\"alignnone size-medium wp-image-31454\" \/><\/p>\n<h3>Visual Studio for Mac:<\/h3>\n<p>To add a platform in Xamarin\/Visual Studio for Mac:<\/p>\n<ol>\n<li>Open the Solution Options by double clicking on the solution in the solution explorer.<\/li>\n<li>Select Build &gt; Configurations on the left (not Run &gt; Configurations).<\/li>\n<li>Select the General tab.<\/li>\n<li>Since we want variants of the <code>Debug<\/code> configuration, in the configuration list select <code>Debug<\/code> and click &#8220;Copy&#8221;. This will copy the current <code>Debug<\/code> settings to your new configuration.<br \/><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/FormsConfigurationsXS.png\" alt=\"\" class=\"alignnone size-full wp-image-31457\" \/><\/li>\n<li>Enter the name for this configuration, in this case keep it the same, <code>Debug<\/code>, since we only want to add a platform not a configuration.<\/li>\n<li>Enter <code>AndroidDevice<\/code> for the Platform field.<\/li>\n<li>Make sure the &#8220;Create Configurations for all solution items&#8221; option is <strong>not<\/strong> checked. We only want this platform for the Android project. If this option were selected, we would be adding this platform to the iOS project as well.<br \/><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/AddPlatformXS.png\" alt=\"\" class=\"alignnone size-full wp-image-31459\" \/><\/li>\n<li>Click &#8220;OK&#8221;.<\/li>\n<li>Repeat steps 4-8 using <code>AndroidEmulator<\/code> for the Platform field.<\/li>\n<li>Since we did not add this new platform to the projects (step 7), we will need to repeat steps 4-8 in the Android Project Options &gt; Build &gt; Configurations. Do this for both the <code>AndroidDevice<\/code> and <code>AndroidEmulator<\/code> platforms.<br \/><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/AddProjectPlatfromXS.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/AddProjectPlatfromXS.png\" alt=\"\" class=\"alignnone size-full wp-image-31463\" \/><\/a><\/li>\n<\/ol>\n<p>You will then have to map the solution custom platform to the project custom platform:<\/p>\n<ol>\n<li>Open the Solution Options &gt; Build &gt; Configurations &gt; Configuration Mappings tab.<\/li>\n<li>Select the <code>AndroidDevice<\/code> platform for the Platform field at the top.<\/li>\n<li>In Configuration column for the Android app project, select <code>Debug|AndroidDevice<\/code>.<br \/><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/ConfigurationMappingsXS.png\" alt=\"\" class=\"alignnone size-full wp-image-31465\" \/><\/li>\n<li>Select the <code>AndroidEmulator<\/code> platform for the Platform field at the top.<\/li>\n<li>In Configuration column for the Android app project, select <code>Debug|AndroidEmulator<\/code>.<\/li>\n<\/ol>\n<p>Now in the main configuration drop down list you will see <code>Debug|AndroidDevice<\/code> and <code>Debug|AndroidEmulator<\/code>.<br \/><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/NewPlatformsXS.png\" alt=\"\" class=\"alignnone size-full wp-image-31467\" \/><\/p>\n<p>You can edit the settings for each platform just as you did for the configurations we set up earlier, just select the correct platform that you want to edit the build settings for in the Platform drop down in the Project Options &gt; Android Build (Mac) settings page.<\/p>\n<h3>Visual Studio (Windows):<\/h3>\n<p>Adding custom platforms is not as straightforward in Visual Studio as it is in Xamarin Studio. You can easily add the custom platform name at the solution level, but adding it at the project level requires some editing of the .csproj file. Here&#8217;s how to do all this in Visual Studio:<\/p>\n<p>Add a solution level platform:<\/p>\n<ol>\n<li>Open the Configuration Manager with the Build &gt; Configuration Manager menu.<\/li>\n<li>Click on the Active Solution Platform drop down and select &#8220;New&#8221;.<br \/><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/NewSolutionPlatformVS.png\" alt=\"\" class=\"alignnone size-full wp-image-31470\" \/><\/li>\n<li>Enter <code>AndroidDevice<\/code> for the Name field.<\/li>\n<li>Select <code>AnyCPU<\/code> in the &#8220;Copy settings from&#8221; drop down list.<\/li>\n<li>Make sure the &#8220;Create new project configurations&#8221; option is <strong>not<\/strong> checked. You will get an error if this is checked since the Android app project does not have an <code>AndroidDevice<\/code> platform yet.<br \/><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/AddSolutionPlatformVS.png\" alt=\"\" class=\"alignnone size-full wp-image-31472\" \/><\/li>\n<li>Click OK.<\/li>\n<li>Repeat steps 2 &#8211; 6 using <code>Androidmulator<\/code> for the Name field.<\/li>\n<\/ol>\n<p>Now for the hard part, adding the new platforms to the Android app project.<\/p>\n<ol>\n<li>Unload the Android app project (right click on the project and select Unload).<\/li>\n<li>Edit the <code>AppName.csproj<\/code> file (right click on the project and select &#8220;Edit .csproj&#8221;.<\/li>\n<li>Paste the following XML right below the opening Project tag:\n<pre class=\"lang:xml decode:true \"><code>\n  AndroidDevice\n  AnyCPU\n\n\n  AndroidEmulator\n  AnyCPU\n<\/code><\/pre>\n<\/li>\n<li>Look for the following element:\n<pre><code><\/code><\/pre>\n<\/li>\n<li>Select all of the text for the above <code>PropertyGroup<\/code> including the opening and closing <code>PropertyGroup<\/code> tag and copy it.<\/li>\n<li>Paste the text twice right below the ending <code>PropertyGroup<\/code> tag copied above.<\/li>\n<li>Edit the pasted property groups, changing:\n<pre class=\"lang:xml decode:true \"><code><\/code><\/pre>\n<p> to <\/p>\n<pre class=\"lang:xml decode:true \"><code><\/code><\/pre>\n<p> for the first copy and <\/p>\n<pre class=\"lang:xml decode:true \"><code><\/code><\/pre>\n<p> for the second copy.<\/li>\n<li>Not required, but best to have a separate <code>OutputPath<\/code> for each platform, so change: \n<pre class=\"lang:xml decode:true \"><code>bin\\Debug<\/code><\/pre>\n<p> to <\/p>\n<pre class=\"lang:xml decode:true \"><code>bin\\AndroidDevice\\Debug<\/code><\/pre>\n<p> for the first copy and <\/p>\n<pre class=\"lang:xml decode:true \"><code>bin\\AndroidEmulator\\Debug<\/code><\/pre>\n<p> for the second copy.<\/li>\n<li>Save and close the .csproj file.<\/li>\n<li>Reload the project.<\/li>\n<\/ol>\n<p>You will then have to map the solution custom platform to the project custom platform:<\/p>\n<ol>\n<li>Open the Configuration Manager again.<\/li>\n<li>Select the <code>AndroidDevice<\/code> platform for the Active Solution Platform.<\/li>\n<li>In Platform column for the Android app project, select <code>AndroidDevice<\/code>.<br \/><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/ConfigurationMappingVS.png\" alt=\"\" class=\"alignnone size-full wp-image-31476\" \/><\/li>\n<li>Select the <code>AndroidEmulator<\/code> platform for the Active Solution Platform.<\/li>\n<li>In Platform column for the Android app project, select <code>AndroidEmulator<\/code>.<\/li>\n<\/ol>\n<p>Now you will want to open the Android project properties and edit the <code>Configuration|Platform<\/code> settings to only build for the relevant architectures, i.e. armeabi-v7s for <code>AndroidDevice<\/code> and x86 for <code>AndroidEmulator<\/code>, like you did earlier for the new configurations.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/VSAndroidAvancedBuildOptions.png\" alt=\"\" width=\"800\" class=\"alignnone size-full wp-image-32011\" \/><\/p>\n<h2>Configuration Mapping<\/h2>\n<p>When we added the configurations above, we added them at the solution level but also added them to each project in the solution by selecting the &#8220;Create Configurations for all solution items&#8221; on Mac and &#8220;Create new project configurations&#8221; in Windows (or added them manually in the <code>.csproj<\/code> file). This way the new configurations are available at the project and the solution level. You can then map solution level configurations to project level configurations using the Configuration Manager in Windows or on Mac using the Solution Options &gt; Build &gt; Configurations &gt; Configuration Mappings tab. You will see that for each project, you can select which project configuration will build when you select the active solution configuration in the Configuration drop-down list.<\/p>\n<p>You can also set which projects build with each solution configuration. If you have a solution with multiple app projects, you can add a configuration to only build the project(s) needed at the time. For a Xamarin Forms app (or any solution with multiple platform projects), you may want to add a configuration that only builds the iOS project (and PCL project if used), and one to only build the Android project (and PCL project if used). This would again speed up build times, so you are only building for the platform you are currently debugging.\n<img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/MappingsXS.png\" alt=\"\" class=\"alignnone size-full wp-image-31480\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/MappingVS.png\" alt=\"\" class=\"alignnone size-medium wp-image-31481\" \/><\/p>\n<h2>Configurations and MSBuild Properties in Your .csproj File<\/h2>\n<p>We touched briefly on the <code>.csproj<\/code> file when adding custom platforms to an app project in Visual Studio since the UI provides no way of doing that as in Xamarin Studio. Mostly you will never have to edit a <code>.csproj<\/code> file but I feel it is useful to at least touch on the items in the <code>.csproj<\/code> file that are affected when you switch the active <code>Configuration|Platform<\/code> in the IDE.<\/p>\n<p>When we added the custom platform above, we copied and pasted a <code>PropertyGroup<\/code> twice to add the new platforms and set the build output path for the new platforms. The property groups that are used for each configuration is simply a set of MSBuild properties and values that will be used when the corresponding <code>Configuration|Platform<\/code> combination is selected for build. For instance, the following property group will be used when the <code>Debug|AnyCPU<\/code>&nbsp; <code>Configuration|Platform<\/code> is selected:<\/p>\n<pre class=\"lang:xml decode:true \">\n\n...\n\n<\/pre>\n<p>When the condition <code>'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'<\/code> is met, then the values for the MSBuild properties in that group will be used. For instance, you will find the below in the above property group:<\/p>\n<pre class=\"lang:xml decode:true \">\nNone\n<\/pre>\n<p>This sets the Linker options to &#8220;None&#8221; when using <code>Debug|AnyCPU<\/code>&nbsp;<code>Configuration|Platform<\/code> combination. Your configurations and platforms are really just a way for you to set a bunch of MSBuild properties to specific values just by choosing a <code>Configuration|Platform<\/code> for your build. If building from the command line, you can manually set any available MSBuild property using the <code>\/p:MSBuildProperty=value<\/code> syntax. In other words, if you wanted to build the <code>Debug|AnyCPU<\/code>&nbsp;<code>Configuration|Platform<\/code> from the command line but wanted to enable the linker option &#8220;Link SDK Assemblies Only&#8221;, you would do the following (Windows):<\/p>\n<pre class=\"lang:xml decode:true \">\nMSBuild.exe MySolution.csproj \/p:Configuration=Debug \/p:Platform=AnyCPU \/p:AndroidLinkMode=SdkOnly\n<\/pre>\n<p>&#8230;or on Mac:<\/p>\n<pre class=\"lang:xml decode:true \">\nMSBuild MySolution.csproj \/p:Configuration=Debug \/p:Platform=AnyCPU \/p:AndroidLinkMode=SdkOnly\n<\/pre>\n<p>Any property you see defined in a <code>PropertyGroup<\/code> in the <code>.csproj<\/code> file can be set to a specific value in the command line with the <code>\/p:PropertyName=PropertyValue<\/code> switch when doing a command line build. Here is the <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/ms164311.aspx\" target=\"_blank\">MSBuild Command Line reference<\/a> for more information.<\/p>\n<h2>Summary<\/h2>\n<p>You have now learned how to create custom configurations and platforms and how to edit them so that the build options you want for a particular scenario can all be set just by selecting the appropriate configuration | platform combination.\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most developers are familiar with the Debug and Release configurations in most solution templates in use. It seems obvious to use the Debug configuration when building your project for debugging and to use the Release configuration when building your project for release. What may be less clear, though, is what&#8217;s actually happening when you switch [&hellip;]<\/p>\n","protected":false},"author":554,"featured_media":39167,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[5,6,4],"class_list":["post-31389","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developers","tag-android","tag-ios","tag-xamarin-platform"],"acf":[],"blog_post_summary":"<p>Most developers are familiar with the Debug and Release configurations in most solution templates in use. It seems obvious to use the Debug configuration when building your project for debugging and to use the Release configuration when building your project for release. What may be less clear, though, is what&#8217;s actually happening when you switch [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/31389","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/users\/554"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/comments?post=31389"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/31389\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media\/39167"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media?parent=31389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/categories?post=31389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/tags?post=31389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}