2013-03-21 70 views
2

我试图让Jenkins构建一个Xamarin.iOS/MonoTouch项目,并且在我的解决方案&项目中创建了一些不同的配置文件来控制如何从一个环境构建到下一个环境。从命令行构建Xamarin.iOS项目时,解决方案文件配置映射无法正常工作

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

我已经尝试了几个不同的命令,但我想我需要的命令是:

/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。我对这里发生的事情感到非常困惑。

+0

原来,问题是我没有提供CPU类型。我一直在使用-c:MySoftwareStaging,当时我应该使用-c:“MySoftwareStaging | iPhone”。由于没有完全匹配,它使用默认值。 – Kirk 2013-03-22 13:14:57

回答

1

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

你可以尝试使用“ - 配置:发布| iPhone”?示例here

+0

我有一个-c:MySoftwareStaging(这是我定义的自定义配置,-c是--configuration标志的简短版本)。我也尝试过使用-p:MySoftwareMT标志,并且每次都得到相同的结果。 – Kirk 2013-03-22 12:41:41

+0

我想我可以用旧的语法来尝试它。看起来mdtool的语法最近已经改变 - 也许随着Xamarin Studio的发布。 – Kirk 2013-03-22 12:44:33

+0

既然你让我走下了最终指向正确方向的道路,你就会得到答案! – Kirk 2013-03-22 13:15:25

相关问题