我試圖讓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 "security unlock-keychain -p 'KeychainPass' ${HOME}/Library/Keychains/iPhoneStuff.keychain"" />
<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 "security unlock-keychain -p 'KeychainPass' ${HOME}/Library/Keychains/iPhoneStuff.keychain"" />
<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。我對這裏發生的事情感到非常困惑。
原來,問題是我沒有提供CPU類型。我一直在使用-c:MySoftwareStaging,當時我應該使用-c:「MySoftwareStaging | iPhone」。由於沒有完全匹配,它使用默認值。 – Kirk 2013-03-22 13:14:57