Search code examples
monodevelopxamarin.iosxamarin-studiomdtool

Solution file configuration mapping not working properly when building Xamarin.iOS projects from the command line


I'm trying to get Jenkins to build a Xamarin.iOS / MonoTouch project, and I've created some different configurations in my solution & project files to control how things are built from one environment to the next.

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.

I've tried a couple of different commands, but I think the command I need is:

/Applications/Xamarin\ Studio.app/Contents/MacOS/mdtool build -t:Build -c:MySoftwareStaging Solution.sln

This solution has 3 projects. I'll start with the solution file.

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

Here are the relevant sections from the MySoftware\MySoftwareMT.csproj:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
    <ProductVersion>10.0.0</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{FC83D683-0444-49B4-8CB5-AA4BD4E548A0}</ProjectGuid>
    <ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <OutputType>Exe</OutputType>
    <RootNamespace>MySoftware</RootNamespace>
    <IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
    <AssemblyName>MySoftware</AssemblyName>
    <ReleaseVersion>1.0 Do Not Change</ReleaseVersion>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
    <DebugSymbols>True</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>False</Optimize>
    <OutputPath>bin\iPhone\Debug</OutputPath>
    <DefineConstants>DEBUG;</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <ConsolePause>False</ConsolePause>
    <CodesignKey>iPhone Developer</CodesignKey>
    <MtouchDebug>True</MtouchDebug>
    <MtouchArch>ARMv7</MtouchArch>
    <MtouchI18n />
    <MtouchSdkVersion>6.0</MtouchSdkVersion>
    <IpaPackageName>MySoftware-Dev</IpaPackageName>
    <BuildIpa>True</BuildIpa>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
    <DebugType>none</DebugType>
    <Optimize>True</Optimize>
    <OutputPath>bin\iPhone\Release</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <ConsolePause>False</ConsolePause>
    <CodesignKey>iPhone Developer</CodesignKey>
    <IpaPackageName />
    <MtouchI18n />
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'MySoftwareDev|iPhone' ">
    <DebugType>none</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\iPhone\Release</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <MtouchI18n />
    <ConsolePause>false</ConsolePause>
    <CodesignKey>iPhone Distribution</CodesignKey>
    <IpaPackageName>MySoftware-Dev</IpaPackageName>
    <CodesignProvision>MyCodesignProvisioningKey</CodesignProvision>
    <BuildIpa>true</BuildIpa>
    <CrashReportingApiKey />
    <MtouchArch>ARMv7</MtouchArch>
    <CustomCommands>
      <CustomCommands>
        <Command type="BeforeBuild" command="bash -c &quot;security unlock-keychain -p 'KeychainPass' ${HOME}/Library/Keychains/iPhoneStuff.keychain&quot;" />
        <Command type="AfterBuild" command="/bin/bash DevDeploymentPlistGenerator.sh -v ${BundleVersion} -b ${BundleIdentifier} -p MySoftware-Dev.plist -i MySoftware-Dev.ipa" workingdir="${SolutionDir}/ShellScripts" />
      </CustomCommands>
    </CustomCommands>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Staging|iPhone' ">
    <DebugType>none</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\iPhone\Release</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <CrashReportingApiKey />
    <IpaPackageName>MySoftware-Staging</IpaPackageName>
    <MtouchArch>ARMv7</MtouchArch>
    <MtouchI18n />
    <ConsolePause>false</ConsolePause>
    <CustomCommands>
      <CustomCommands>
        <Command type="BeforeBuild" command="bash -c &quot;security unlock-keychain -p 'KeychainPass' ${HOME}/Library/Keychains/iPhoneStuff.keychain&quot;" />
        <Command type="AfterBuild" command="/bin/bash DevDeploymentPlistGenerator.sh -v ${BundleVersion} -b ${BundleIdentifier} -p MySoftware-Staging.plist -i MySoftware-Staging.ipa" workingdir="${SolutionDir}/ShellScripts" />
      </CustomCommands>
    </CustomCommands>
    <BuildIpa>true</BuildIpa>
    <CodesignKey>iPhone Distribution</CodesignKey>
    <CodesignProvision>MyCodesignProvisioningKey</CodesignProvision>
  </PropertyGroup>
</Project>

And here is a chunk of the mdtool output from the aforementioned command:


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

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.

UPDATE: Based on the answer from @jonathanpeppers I did some additional testing. I cleaned the solution (using --target:Clean), and then I tried building each project independently using the --project:Myproject flag to mdtool. For the first 2 projects ("MySoftware.Core.MT" & "MySoftware.Presentation") I used --configuration:Release. They built, but the dlls were placed in /bin/Debug and not Release. When I attempted to finally build "MySoftwareMT" using --configuration:Staging, the build fails because it can't find the DLLs for the other projects. I'm seriously confused about what is happening here.


Solution

  • It doesn't look like you are telling mdtool which configuration to build. I don't think mdtool uses the startup project, it probably just picks the first configuration.

    Can you try using "--configuration:Release|iPhone"? example here.