从命令行构建Xamarin.iOS项目时,解决方案文件配置映射无法正常工作

时间:2013-03-21 04:39:54

标签: monodevelop xamarin.ios xamarin-studio mdtool

我正在尝试让Jenkins构建一个Xamarin.iOS / MonoTouch项目,并且我在我的解决方案中创建了一些不同的配置。项目文件,用于控制从一个环境到下一个环境的构建方式。

当我在Xamarin Studio中构建时,事情似乎按预期工作。但是,当我从命令行构建时,StartUp项目没有使用正确的配置构建。

我尝试过几个不同的命令,但我认为我需要的命令是:

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

此解决方案有3个项目。我将从解决方案文件开始。

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

以下是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>

这是上述命令的mdtool输出的一部分:


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

关于为什么会发生这种情况的任何想法?当我在Xamarin Studio中运行它时,一切正常。只是从命令行我才看到奇怪的行为。

更新:根据@jonathanpeppers的答案,我做了一些额外的测试。我清理了解决方案(使用--target:Clean),然后我尝试使用--project:Myproject标志独立构建每个项目mdtool。对于前两个项目(“MySoftware.Core.MT”和“MySoftware.Presentation”),我使用了--configuration:Release。他们构建了,但dll被放在/ bin / Debug而不是Release。当我尝试使用--configuration:Staging最终构建“MySoftwareMT”时,构建失败,因为它无法找到其他项目的DLL。我对这里发生的事情感到非常困惑。

1 个答案:

答案 0 :(得分:1)

看起来你没有告诉mdtool要构建哪种配置。我不认为mdtool使用启动项目,它可能只选择第一个配置。

您可以尝试使用“--configuration:Release | iPhone”吗?例如here