I am trying to setup a CI build for my Xamarin.iOS application using TeamCity and FAKE and upload the result (.ipa file) to HockeyApp. I am running in a small problem.
I managed to trigger the FAKE build script from TeamCity and also build my application successfully. The next step would be to call the "HockeyApp" method from the "HockeyAppHelper" module from FakeLib, but todo this I need the path to the .ipa file. All examples I find just hardcode the path (something like bin/iPhone/Release/*.ipa
) however in my case the .ipa will by dropped in a folder containing the a timestamp (like bin/iPhone/Release/MyApp 2017-01-24 17-16-56/MyApp.ipa
).
Question is how do I get hold of the .ipa file in the build script (because of the timestamp I cannot hardcode the path)?
Below is the section of the FAKE script responsible for building and uploading the .ipa:
Target "ios-adhoc" (fun () ->
RestorePackages "RidderCRM.iOS.sln"
UpdatePlist version versionNumber "RidderCRM.iOS"
iOSBuild (fun defaults ->
{defaults with
ProjectPath = "RidderCRM.iOS.sln"
Configuration = "Release"
Platform = "iPhone"
Target = "Build"
BuildIpa = true
Properties = [ "CodesignKey", "iPhone Distribution"; "CodesignProvision", "Automatic:AdHoc" ]
})
let appPath = Directory.EnumerateFiles(Path.Combine("RidderCRM.iOS", "bin", "iPhone", "Release"), "*.ipa").First()
TeamCityHelper.PublishArtifact appPath
HockeyApp (fun p ->
{p with
ApiToken = Environment.GetEnvironmentVariable("HockeyAppApiToken")
File = appPath
}) |> ignore
)
Seeing that this is more of an issue of what the actual MSBuild Task is doing in Xamarin.iOS.Common.targets
, there are many things you can do.
Xamarin.iOS.Common.targets
file to remove the date time stamp. (Not so great)Target
which invokes the <Copy>
Task. (Better)IpaPackageDir
property to specify what the directory should be. (Best)In short the problem of the TimeStamp comes directly from this element:
<IpaPackageDir Condition="'$(IpaPackageDir)' == ''">$(DeviceSpecificOutputPath)$(_AppBundleName) $([System.DateTime]::Now.ToString('yyyy-MM-dd HH-mm-ss'))</IpaPackageDir>
How would we do each one of these?
Xamarin.iOS.Common.targets
file and remove the timestamp. It's usually a good idea to note edit .targets
if you aren't familiar with them. Also updating Xamarin can override these.<Target Name="AfterBuild">
definition with a simple copy task inside: <Copy SourceFiles="$(IpaPackagePath)" DestinationFolder="$(OutputPath)" />
<IpaPackageDir>
directly via:
<PropertyGroup>
<IpaPackageDir>$(OutputPath)</IpaPackageDir>
</PropertyGroup>
Note on #3:
A new MSBuild property IpaPackageDir has been added to make it easy to customize the .ipa file output location. If IpaPackageDir is set to a custom location, the .ipa file will be placed in that location instead of the default timestamped subdirectory.