Starting with Xamarin 3.5, thanks to the new "Unified Build" feature, if the Mac build host is available and properly paired, the Build
target alone will run the remote build step in addition to the local build step.
Tested on 2 October 2014, with:
Pair to the build host via Visual Studio. This will cache the pairing information (the PIN and the server address) in %LOCALAPPDATA%\Xamarin\MonoTouch
.
Quit Visual Studio so that it won't conflict with the command line build.
Run a command line build:
msbuild HelloWorld1\HelloWorld1.csproj /t:Build
Additional example for step 3, to build an Ad-Hoc IPA:
msbuild HelloWorld1\HelloWorld1.csproj /t:Build /p:Configuration=Ad-Hoc;Platform=iPhone
Starting in Xamarin 3.1 (tested on 3.1.228) it's no longer necessary to specify the BSAT
, HttpPort
, or ServerAddress
parameters when running the _RemoteBuild
target on the command line. The "MonoTouchBuildNative_SayHello" task has been updated so that it finds these values automatically during a command line or TFS build.
Tested on 23 July 2014, with:
Pair to the build host via Visual Studio. This will cache the pairing information (the PIN and the server address) in %LOCALAPPDATA%\Xamarin\MonoTouch
.
Quit Visual Studio so that it won't conflict with the command line build.
Run a command line build:
msbuild HelloWorld1\HelloWorld1.csproj /t:Build;_RemoteBuild
There is no need to use Visual Studio to re-pair after rebooting.
Tested on 30 April 2014, with:
The process of building iOS projects via TFS is still tricky because every time you disconnect and reconnect to the build host, the HttpPort
and BSAT
can change. Also, the TFS build agent cannot perform this pairing, so TFS must reuse Visual Studio's connection. As a result, it's necessary to leave Visual Studio connected to the build host to preserve the HttpPort
and BSAT
. That said, as long as you keep VS paired to the build host by leaving any Xamarin.iOS project open, I've found that you can then build that project or any other Xamarin.iOS project you like.
As mentioned on [1], further improvements to the TFS build scenario are still planned or in progress. It's also likely that the steps I list below will stop working or need updates as the _RemoteBuild
target changes in future releases.
[1] https://bugzilla.xamarin.com/show_bug.cgi?id=17748
Here are the steps I followed. In my case, the repairing in steps 3-5 was important during the first run-through. After that, as long as VS was paired, I was able to build via TFS too.
Install TFS (tested with TFS 2013 Trial).
Create a new HelloWorld1 Xamarin.iOS project in a Team Project. Also be sure to set the Application Name and Identifier to avoid build errors later. Then "Check In" the project to the source control.
Quit Visual Studio, and "Unpair" the Xamarin.iOS Build Host App.
Restart Visual Studio, and open the HelloWorld1 project.
Click "Pair" in the Xamarin.iOS Build Host App, and enter the PIN in Visual Studio.
Enable diagnostic build output verbosity [2].
[2] http://msdn.microsoft.com/en-us/library/jj651643.aspx
Build the project once using the "Start" button, and then stop debugging.
Find the "MonoTouchBuildNative_SayHello" task in the build output, and copy down the values of the following "Task Parameters" :
Create a new Build Definition.
Set the "Build Defaults -> Staging Location" to "This build does not copy output files to a drop folder".
Set "Process -> 2. Build -> 1. Projects" to:
$/TeamProjectName/HelloWorld1/HelloWorld1/HelloWorld1.csproj
Set "Process -> 2. Build -> 5. Advanced -> MSBuild arguments" to:
/t:Build;_RemoteBuild /p:HttpPort=%HTTP_PORT%;ServerAddress=%SERVER_ADDRESS%;BSAT=%BSAT%
Replace %HTTP_PORT%
, %SERVER_ADDRESS%
, and %BSAT%
with the corresponding values from the "Project setup" step 8 from above.
Optionally, set the MSbuild platform to iPhone|Debug
, iPhoneSimulator|Debug
, or similar.
Save the Build Definition.
Right click on the newly created Build Definition, select "Queue New Build", and click "Queue".
With some luck, the build will complete successfully.
At this point, I was also able to build successfully from a "Developer Command Prompt" using MSBuild:
msbuild HelloWorld1/HelloWorld1.csproj /t:Build;_RemoteBuild /p:HttpPort=%HTTP_PORT%;ServerAddress=%SERVER_ADDRESS%;BSAT=%BSAT%
I also quickly tested leaving Visual Studio running with the HelloWorld1 project open, and then queueing and building a different Xamarin.iOS project via the TFS web interface.