title: Solution file configuration mapping not working properly when building Xamarin.iOS projects from the command line
body: <p>I'm trying to get Jenkins to build a Xamarin.iOS / MonoTouch project, and I've created some different configurations in my solution &amp; project files to control how things are built from one environment to the next.</p>
  
  <p>When I build from within Xamarin Studio, things seem to work as expected. However, when I build from the command line, the StartUp project isn't being built with the correct configuration.</p>
  
  <p>I've tried a couple of different commands, but I think the command I need is:</p>
  
  <p><code>/Applications/Xamarin\ Studio.app/Contents/MacOS/mdtool build -t:Build -c:MySoftwareStaging Solution.sln</code></p>
  
  <p>This solution has 3 projects. I'll start with the solution file.</p>
  
  <pre><code>Microsoft Visual Studio Solution File, Format Version 11.00
  # Visual Studio 2010
  Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySoftwareMT", "MySoftware\MySoftwareMT.csproj", "{FC83D683-0444-49B4-8CB5-AA4BD4E548A0}"
  EndProject
  Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySoftware.Core.MT", "MySoftware.Core\MySoftware.Core.MT.csproj", "{52709902-8F51-40F1-9CC8-F5EA0EC5465C}"
  EndProject
  Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySoftware.Presentation", "MySoftware.Presentation\MySoftware.Presentation.csproj", "{463229B1-C94D-44EB-9775-EF7164E739E1}"
  EndProject
  Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ShellScripts", "ShellScripts", "{7838E2BF-9BF3-4554-AD65-55764DE3926C}"
      ProjectSection(SolutionItems) = preProject
          ShellScripts\DevDeploymentPlistGenerator.sh = ShellScripts\DevDeploymentPlistGenerator.sh
          ShellScripts\Version_Environment_Settings.sh = ShellScripts\Version_Environment_Settings.sh
      EndProjectSection
  EndProject
  Global
      GlobalSection(SolutionConfigurationPlatforms) = preSolution
          Debug|iPhoneSimulator = Debug|iPhoneSimulator
          Release|iPhoneSimulator = Release|iPhoneSimulator
          Debug|iPhone = Debug|iPhone
          Release|iPhone = Release|iPhone
          Ad-Hoc|iPhone = Ad-Hoc|iPhone
          AppStore|iPhone = AppStore|iPhone
          MySoftwareDev|iPhone = MySoftwareDev|iPhone
          MySoftwareStaging|iPhone = MySoftwareStaging|iPhone
      EndGlobalSection
      GlobalSection(ProjectConfigurationPlatforms) = postSolution
          {463229B1-C94D-44EB-9775-EF7164E739E1}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
          {463229B1-C94D-44EB-9775-EF7164E739E1}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
          {463229B1-C94D-44EB-9775-EF7164E739E1}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
          {463229B1-C94D-44EB-9775-EF7164E739E1}.AppStore|iPhone.Build.0 = Debug|Any CPU
          {463229B1-C94D-44EB-9775-EF7164E739E1}.MySoftwareDev|iPhone.ActiveCfg = Release|Any CPU
          {463229B1-C94D-44EB-9775-EF7164E739E1}.MySoftwareDev|iPhone.Build.0 = Release|Any CPU
          {463229B1-C94D-44EB-9775-EF7164E739E1}.MySoftwareStaging|iPhone.ActiveCfg = Release|Any CPU
          {463229B1-C94D-44EB-9775-EF7164E739E1}.MySoftwareStaging|iPhone.Build.0 = Release|Any CPU
          {463229B1-C94D-44EB-9775-EF7164E739E1}.Debug|iPhone.ActiveCfg = Debug|Any CPU
          {463229B1-C94D-44EB-9775-EF7164E739E1}.Debug|iPhone.Build.0 = Debug|Any CPU
          {463229B1-C94D-44EB-9775-EF7164E739E1}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
          {463229B1-C94D-44EB-9775-EF7164E739E1}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
          {463229B1-C94D-44EB-9775-EF7164E739E1}.Release|iPhone.ActiveCfg = Release|Any CPU
          {463229B1-C94D-44EB-9775-EF7164E739E1}.Release|iPhone.Build.0 = Release|Any CPU
          {463229B1-C94D-44EB-9775-EF7164E739E1}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
          {463229B1-C94D-44EB-9775-EF7164E739E1}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
          {52709902-8F51-40F1-9CC8-F5EA0EC5465C}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
          {52709902-8F51-40F1-9CC8-F5EA0EC5465C}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
          {52709902-8F51-40F1-9CC8-F5EA0EC5465C}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
          {52709902-8F51-40F1-9CC8-F5EA0EC5465C}.AppStore|iPhone.Build.0 = Debug|Any CPU
          {52709902-8F51-40F1-9CC8-F5EA0EC5465C}.MySoftwareDev|iPhone.ActiveCfg = Release|Any CPU
          {52709902-8F51-40F1-9CC8-F5EA0EC5465C}.MySoftwareDev|iPhone.Build.0 = Release|Any CPU
          {52709902-8F51-40F1-9CC8-F5EA0EC5465C}.MySoftwareStaging|iPhone.ActiveCfg = Release|Any CPU
          {52709902-8F51-40F1-9CC8-F5EA0EC5465C}.MySoftwareStaging|iPhone.Build.0 = Release|Any CPU
          {52709902-8F51-40F1-9CC8-F5EA0EC5465C}.Debug|iPhone.ActiveCfg = Debug|Any CPU
          {52709902-8F51-40F1-9CC8-F5EA0EC5465C}.Debug|iPhone.Build.0 = Debug|Any CPU
          {52709902-8F51-40F1-9CC8-F5EA0EC5465C}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
          {52709902-8F51-40F1-9CC8-F5EA0EC5465C}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
          {52709902-8F51-40F1-9CC8-F5EA0EC5465C}.Release|iPhone.ActiveCfg = Release|Any CPU
          {52709902-8F51-40F1-9CC8-F5EA0EC5465C}.Release|iPhone.Build.0 = Release|Any CPU
          {52709902-8F51-40F1-9CC8-F5EA0EC5465C}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
          {52709902-8F51-40F1-9CC8-F5EA0EC5465C}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
          {FC83D683-0444-49B4-8CB5-AA4BD4E548A0}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
          {FC83D683-0444-49B4-8CB5-AA4BD4E548A0}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
          {FC83D683-0444-49B4-8CB5-AA4BD4E548A0}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
          {FC83D683-0444-49B4-8CB5-AA4BD4E548A0}.AppStore|iPhone.Build.0 = AppStore|iPhone
          {FC83D683-0444-49B4-8CB5-AA4BD4E548A0}.MySoftwareDev|iPhone.ActiveCfg = MySoftwareDev|iPhone
          {FC83D683-0444-49B4-8CB5-AA4BD4E548A0}.MySoftwareDev|iPhone.Build.0 = MySoftwareDev|iPhone
          {FC83D683-0444-49B4-8CB5-AA4BD4E548A0}.MySoftwareStaging|iPhone.ActiveCfg = Staging|iPhone
          {FC83D683-0444-49B4-8CB5-AA4BD4E548A0}.MySoftwareStaging|iPhone.Build.0 = Staging|iPhone
          {FC83D683-0444-49B4-8CB5-AA4BD4E548A0}.Debug|iPhone.ActiveCfg = Debug|iPhone
          {FC83D683-0444-49B4-8CB5-AA4BD4E548A0}.Debug|iPhone.Build.0 = Debug|iPhone
          {FC83D683-0444-49B4-8CB5-AA4BD4E548A0}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
          {FC83D683-0444-49B4-8CB5-AA4BD4E548A0}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
          {FC83D683-0444-49B4-8CB5-AA4BD4E548A0}.Release|iPhone.ActiveCfg = Release|iPhone
          {FC83D683-0444-49B4-8CB5-AA4BD4E548A0}.Release|iPhone.Build.0 = Release|iPhone
          {FC83D683-0444-49B4-8CB5-AA4BD4E548A0}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
          {FC83D683-0444-49B4-8CB5-AA4BD4E548A0}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
      EndGlobalSection
      GlobalSection(NestedProjects) = preSolution
      EndGlobalSection
      GlobalSection(MonoDevelopProperties) = preSolution
          StartupItem = MySoftware\MySoftwareMT.csproj
          version = 1.0
      EndGlobalSection
  EndGlobal
  </code></pre>
  
  <p>Here are the relevant sections from the MySoftware\MySoftwareMT.csproj:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;PropertyGroup&gt;
      &lt;Configuration Condition=" '$(Configuration)' == '' "&gt;Debug&lt;/Configuration&gt;
      &lt;Platform Condition=" '$(Platform)' == '' "&gt;iPhoneSimulator&lt;/Platform&gt;
      &lt;ProductVersion&gt;10.0.0&lt;/ProductVersion&gt;
      &lt;SchemaVersion&gt;2.0&lt;/SchemaVersion&gt;
      &lt;ProjectGuid&gt;{FC83D683-0444-49B4-8CB5-AA4BD4E548A0}&lt;/ProjectGuid&gt;
      &lt;ProjectTypeGuids&gt;{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}&lt;/ProjectTypeGuids&gt;
      &lt;OutputType&gt;Exe&lt;/OutputType&gt;
      &lt;RootNamespace&gt;MySoftware&lt;/RootNamespace&gt;
      &lt;IPhoneResourcePrefix&gt;Resources&lt;/IPhoneResourcePrefix&gt;
      &lt;AssemblyName&gt;MySoftware&lt;/AssemblyName&gt;
      &lt;ReleaseVersion&gt;1.0 Do Not Change&lt;/ReleaseVersion&gt;
    &lt;/PropertyGroup&gt;
    &lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' "&gt;
      &lt;DebugSymbols&gt;True&lt;/DebugSymbols&gt;
      &lt;DebugType&gt;full&lt;/DebugType&gt;
      &lt;Optimize&gt;False&lt;/Optimize&gt;
      &lt;OutputPath&gt;bin\iPhone\Debug&lt;/OutputPath&gt;
      &lt;DefineConstants&gt;DEBUG;&lt;/DefineConstants&gt;
      &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt;
      &lt;WarningLevel&gt;4&lt;/WarningLevel&gt;
      &lt;ConsolePause&gt;False&lt;/ConsolePause&gt;
      &lt;CodesignKey&gt;iPhone Developer&lt;/CodesignKey&gt;
      &lt;MtouchDebug&gt;True&lt;/MtouchDebug&gt;
      &lt;MtouchArch&gt;ARMv7&lt;/MtouchArch&gt;
      &lt;MtouchI18n /&gt;
      &lt;MtouchSdkVersion&gt;6.0&lt;/MtouchSdkVersion&gt;
      &lt;IpaPackageName&gt;MySoftware-Dev&lt;/IpaPackageName&gt;
      &lt;BuildIpa&gt;True&lt;/BuildIpa&gt;
    &lt;/PropertyGroup&gt;
    &lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' "&gt;
      &lt;DebugType&gt;none&lt;/DebugType&gt;
      &lt;Optimize&gt;True&lt;/Optimize&gt;
      &lt;OutputPath&gt;bin\iPhone\Release&lt;/OutputPath&gt;
      &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt;
      &lt;WarningLevel&gt;4&lt;/WarningLevel&gt;
      &lt;ConsolePause&gt;False&lt;/ConsolePause&gt;
      &lt;CodesignKey&gt;iPhone Developer&lt;/CodesignKey&gt;
      &lt;IpaPackageName /&gt;
      &lt;MtouchI18n /&gt;
    &lt;/PropertyGroup&gt;
    &lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'MySoftwareDev|iPhone' "&gt;
      &lt;DebugType&gt;none&lt;/DebugType&gt;
      &lt;Optimize&gt;true&lt;/Optimize&gt;
      &lt;OutputPath&gt;bin\iPhone\Release&lt;/OutputPath&gt;
      &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt;
      &lt;WarningLevel&gt;4&lt;/WarningLevel&gt;
      &lt;MtouchI18n /&gt;
      &lt;ConsolePause&gt;false&lt;/ConsolePause&gt;
      &lt;CodesignKey&gt;iPhone Distribution&lt;/CodesignKey&gt;
      &lt;IpaPackageName&gt;MySoftware-Dev&lt;/IpaPackageName&gt;
      &lt;CodesignProvision&gt;MyCodesignProvisioningKey&lt;/CodesignProvision&gt;
      &lt;BuildIpa&gt;true&lt;/BuildIpa&gt;
      &lt;CrashReportingApiKey /&gt;
      &lt;MtouchArch&gt;ARMv7&lt;/MtouchArch&gt;
      &lt;CustomCommands&gt;
        &lt;CustomCommands&gt;
          &lt;Command type="BeforeBuild" command="bash -c &amp;quot;security unlock-keychain -p 'KeychainPass' ${HOME}/Library/Keychains/iPhoneStuff.keychain&amp;quot;" /&gt;
          &lt;Command type="AfterBuild" command="/bin/bash DevDeploymentPlistGenerator.sh -v ${BundleVersion} -b ${BundleIdentifier} -p MySoftware-Dev.plist -i MySoftware-Dev.ipa" workingdir="${SolutionDir}/ShellScripts" /&gt;
        &lt;/CustomCommands&gt;
      &lt;/CustomCommands&gt;
    &lt;/PropertyGroup&gt;
    &lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Staging|iPhone' "&gt;
      &lt;DebugType&gt;none&lt;/DebugType&gt;
      &lt;Optimize&gt;true&lt;/Optimize&gt;
      &lt;OutputPath&gt;bin\iPhone\Release&lt;/OutputPath&gt;
      &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt;
      &lt;WarningLevel&gt;4&lt;/WarningLevel&gt;
      &lt;CrashReportingApiKey /&gt;
      &lt;IpaPackageName&gt;MySoftware-Staging&lt;/IpaPackageName&gt;
      &lt;MtouchArch&gt;ARMv7&lt;/MtouchArch&gt;
      &lt;MtouchI18n /&gt;
      &lt;ConsolePause&gt;false&lt;/ConsolePause&gt;
      &lt;CustomCommands&gt;
        &lt;CustomCommands&gt;
          &lt;Command type="BeforeBuild" command="bash -c &amp;quot;security unlock-keychain -p 'KeychainPass' ${HOME}/Library/Keychains/iPhoneStuff.keychain&amp;quot;" /&gt;
          &lt;Command type="AfterBuild" command="/bin/bash DevDeploymentPlistGenerator.sh -v ${BundleVersion} -b ${BundleIdentifier} -p MySoftware-Staging.plist -i MySoftware-Staging.ipa" workingdir="${SolutionDir}/ShellScripts" /&gt;
        &lt;/CustomCommands&gt;
      &lt;/CustomCommands&gt;
      &lt;BuildIpa&gt;true&lt;/BuildIpa&gt;
      &lt;CodesignKey&gt;iPhone Distribution&lt;/CodesignKey&gt;
      &lt;CodesignProvision&gt;MyCodesignProvisioningKey&lt;/CodesignProvision&gt;
    &lt;/PropertyGroup&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>And here is a chunk of the <code>mdtool</code> output from the aforementioned command:</p>
  
  <pre><code>
  MonoDevelop Build Tool
  Loading solution: /Users/kirk/Projects/MySoftware_Trunk/src/MySoftware/MySoftware.sln
     Loading solution: /Users/kirk/Projects/MySoftware_Trunk/src/MySoftware/MySoftware.sln
        Loading projects ..
  Building Solution: MySoftware (MySoftwareStaging)
     Building: MySoftware.Core.MT (Debug)
        Performing main compilation...
  
  ......output removed.....
  
        Build complete -- 0 errors, 0 warnings
     Building: MySoftware.Presentation (Debug)
        Performing main compilation...
  
  ......output removed.....
  
        Build complete -- 0 errors, 0 warnings
     Building: MySoftwareMT (Debug|iPhoneSimulator)
        Performing main compilation...
  
  ......output removed.....
  
       Build complete -- 0 errors, 3 warnings
  </code></pre>
  
  <p>Any ideas about why this might be happening? When I run it in Xamarin Studio, everything works as it should. It's only from the command line that I'm seeing odd behavior.</p>
  
  <p><strong>UPDATE:</strong> Based on the answer from @jonathanpeppers I did some additional testing. I cleaned the solution (using <code>--target:Clean</code>), and then I tried building each project independently using the <code>--project:Myproject</code> flag to <code>mdtool</code>. For the first 2 projects ("MySoftware.Core.MT" &amp; "MySoftware.Presentation") I used <code>--configuration:Release</code>. They built, but the dlls were placed in /bin/Debug and not Release. When I attempted to finally build "MySoftwareMT" using <code>--configuration:Staging</code>, the build fails because it can't find the DLLs for the other projects. I'm seriously confused about what is happening here.</p>