Bug 34902 - Unable to remote build iOS app from Visual Studio command line
Summary: Unable to remote build iOS app from Visual Studio command line
Status: VERIFIED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: 4.0.0 (C6)
Hardware: PC Windows
: Normal normal
Target Milestone: 4.0.0 (C6)
Assignee: Enzo Heredia
URL:
Depends on:
Blocks:
 
Reported: 2015-10-15 09:31 UTC by Guillaume
Modified: 2015-11-26 10:39 UTC (History)
9 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
The build output from the command line specified in the bug description (5.69 KB, text/plain)
2015-10-15 09:32 UTC, Guillaume
Details
Build failed with iOS class library dependency (10.90 KB, application/octet-stream)
2015-10-16 13:06 UTC, Guillaume
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description Guillaume 2015-10-15 09:31:16 UTC
%% Steps to reproduce
1. Create a unified iPhone HelloWorld project (Blank)
2. In project options:
    - Enable IPA generation for configs Realease/iPhone & AppStore/iPhone
    - Assign a proper application identifier in order to allow build configurations to succeed (development and distribution certificate)
3. Close Visual Studio and open a Visual Studio Developer Command Prompt
4. Run the command `C:\Path\To\The\Solution\TheTestSolution.sln /p:Configuration=Release;Platform=iPhone`

%% Expected results
The build should be properly performed locally && remotely on the mac in order to allow the IPA generation (for both Release and AppStore configurations).

%% Current results
Only the local build is performed.

%% Details
This was properly working with Xamarin for Visual Studio 3.11 (we have been using it in our TFS builds since December 2014) but seems no longer functional since 4.0.

Find attached the build log from the Windows box.
I think the important part is about the _SayHello target which was already used in Xamarin.VS 3.11 but no longer properly runs since 4.0.
`(_SayHello target) -> 
  C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Windows.After.targets(54,5): warning VSXRunBuildLocally: The project TestRemoteBuild was built while disconnected from a Mac agent, so only the main assembly was compiled. Connect to a Xamarin Mac build agent to build the full application. [C:\Users\ggirard\Documents\Visual Studio 2013\Projects\TestRemoteBuild\TestRemoteBuild\TestRemoteBuild.csproj]`


%% Versions
> Windows box
Microsoft Visual Studio Premium 2013
Version 12.0.40629.00 Update 5
Xamarin   4.0.0.1566 (5abb0de)

> OS X Box
OS X Yosemite 10.10.5
Xamarin.iOS
Version: 9.2.0.84 (Business Edition)
Hash: b5396c2
Branch: master
Build date: 2015-09-30 15:22:15-0400
Comment 1 Guillaume 2015-10-15 09:32:12 UTC
Created attachment 13342 [details]
The build output from the command line specified in the bug description
Comment 2 Arpit Jha 2015-10-16 05:19:48 UTC
I have checked this issue and able to reproduce this issue with the help of bug description build  using Xamarin.VisualStudio_4.0.0.1587_74739827abbb98b1b6e751ed8428dff3d6fee28d  monotouch-9.2.0.93_1a6b88f2b2305d50bad065ae4c7292ab6348ff60


Build output: https://gist.github.com/Arpit360/44518a96ff88c666f144

REGRESSION: This issue is working fine with latest stable build
Xamarin.VisualStudio_3.11.1537_a11147b697db127e63af3b0811811a01c30a178e 
monotouch-9.0.1.29_1d27ac2cea28ce4baac7ca238122e0a8aea5d17a


Build output: https://gist.github.com/Arpit360/0c857fd5d57530ecabad

Environment Info:
Windows: https://gist.github.com/Arpit360/d6a2c902c3593b4f7264
Mac: https://gist.github.com/Arpit360/0c857fd5d57530ecabad
Comment 3 Arpit Jha 2015-10-16 08:44:45 UTC
An update to comment 2:
Mac Environment : https://gist.github.com/Arpit360/438405f2b46da57a282f
Comment 4 Joaquin Jares 2015-10-16 12:24:51 UTC
We changed the parameters for msbuild in 4.0. You now need to add new properties for ServerAddress and ServerUser to (/p:ServerAddress=[myip|hostname] /p:ServerUser[username]). An address and user that will connect via ssh and has been connected once from VS will work (we avoid requiring a password in command line that way). Please let me know if that works for you, and Arpit, please try it to verify that everything's working correctly.

Thanks,
J
Comment 5 Guillaume 2015-10-16 13:05:55 UTC
@Joaquin Thanks for the extra info, it helped. I have been able to properly build and generate the IPA for the HelloWorld project but I still can't build my solution.

The problem seems to be due to class library dependencies. I have been able to reproduce the issue by simply adding a new iOS class library project in the HelloWorld solution.
As soon as you did this, both project are uploaded to the remote server, but the iOS app is no longer compiled in that case. The resulting build status is FAILED.

I am going to attach my sample project used to reproduce the issue.
The command line I used for the build was C:\Path\To\My\Solution\TestRemoteBuild>msbuild TestRemoteBuild.sln /p:Configuration=Release;Platform=iPhone;ServerAddress=INF-MMAC-003.local;ServerUser=ggirard

An other point: I saw you are now storing the server address/user in C:\Users\ggirard\AppData\Local\Xamarin\MonoTouch\id_rsa.pub with info detailed as "user@machinename.local". Do you have any single parameter available for the command line to pass info with this format in the command line? (my aim is to make something generic for our build server which retrieves this data from your file at build time to avoid define it in every build definition).
Comment 6 Guillaume 2015-10-16 13:06:39 UTC
Created attachment 13378 [details]
Build failed with iOS class library dependency
Comment 7 Joaquin Jares 2015-10-16 13:57:04 UTC
That le is public key and fairly standard. Having that file lets us not need to store your password, which was a security goal in our design. 

As per the user/server, I don't think we have anything that will guess it for you. We do store it, though, in the registry (which is undocumented and may change, but still available).

My advice would be to have a .csproj.user file for your iOS projects with ServerAddress and ServerUser. That will let you change it per user/project, and you won't need to pass that to the command line.

I'll take a look at your project.
Comment 8 Joaquin Jares 2015-10-16 13:57:25 UTC
(That file... keyboard issues :S)
Comment 9 Joaquin Jares 2015-10-16 14:38:44 UTC
@guillaume, try this:
msbuild TestRemoteBuild.sln
/p:Configuration=Release /p:Platform=iPhone /p:ServerAddress=INF-MMAC-003.local /p:ServerUser=ggirard

I just tried that on my box with your solution and it worked beautifully.
Comment 10 Guillaume 2015-10-16 15:01:52 UTC
@Joaquin your command looks like the same as mine. But I tried it anyway and still:
  - Build status mark as FAILED.
  - No .ipa generated on the build server, neither .app.

I made a gist of the build log available here https://gist.github.com/ggirard-distech/9f636a7c172e6a83a12d

Did you clean your remote mtbs build cache prior to run it?
You are maybe looking at file resulting from a previous build not issued from the command line...

On my OSX box ~/Library/Caches/Xamarin/mtbs/build/TestRemoteBuild/GUID/ does not contain any "bin" folder resulting from an effective build. I only have Entitlement.plist and Info.plist files with obj and Resources folder.
Sorry but with time I got no longer trust in running the Clean target on Xamarin project... we configured our build script to delete the ~/Library/Caches/Xamarin/mtbs/build folder.
Comment 11 Enzo Heredia 2015-10-16 15:03:34 UTC
There is a related issue https://bugzilla.xamarin.com/show_bug.cgi?id=34970
Comment 12 Guillaume 2015-10-16 15:06:30 UTC
@Enzo sorry but your link point to a private bug...
Comment 13 Joaquin Jares 2015-10-16 15:49:52 UTC
Yep, my bad. There is an activation issue when running from command line. I have asked Enzo to create a new bug for that, and we'll investigate there. I'm hoping to have someone fix it before the next refresh.
Comment 14 Enzo Heredia 2015-10-16 15:50:42 UTC
Sorry, now it's public.
Comment 15 Guillaume 2015-10-16 16:03:12 UTC
Thanks, I will wait for next public alpha and keep you posted if I notice something. Thanks for your help.
Comment 16 Jose Gallardo 2015-10-16 16:59:31 UTC
@Guillaume: As @Enzo mentioned, you might be getting an activation conflict error.

Couple of comments:

1. Do you have XS open on the Mac? That might cause some activation conflicts, as the Xamarin account from VS needs to be pushed to the Mac.

2. For CI environments, you might want to use /ServerPassword=yourMacSSHPassword as an additional parameter if you don't want to have the environment pre-paired.

Hope that helps.
Comment 17 Guillaume 2015-10-16 17:09:39 UTC
@Jose here my answers

1. No XS, Only XCode in order to use the devices and organizer panes.
2. I'm ok with the pre-paired solution.

Regarding the activation issue, I don't think it is related to my setup as @Enzo is able to reproduce it in 34970.
Comment 18 Arpit Jha 2015-10-19 02:50:26 UTC
Thanks @joaquin, I have checked this issue with the help of https://bugzilla.xamarin.com/show_bug.cgi?id=34902#c9 
and I am still observing the issue.

Command I am running

C:\Users\Arpit\Documents\Visual Studio 2013\Projects\App11>C:\Windows\Microsoft.
NET\Framework\v4.0.30319\MSBuild.exe /t:Build /p:Configuration=Release /p:Platform=iPhone /p:ServerAddress=mac360-xamarins-Mac-mini.local /p:ServerUser=mac360xamarin App11.sln


Full output: https://gist.github.com/Arpit360/1f036e3f28c7718a70cb

Also I deleted the caches from ~/Library/Caches/Xamarin/mtbs/build but getting same behaviour. 

Environment Info:
VS 2013 update 5
OS X  : 10.10.5
Xamarin.VisualStudio_4.0.0.1591_6f941dd0638630c2632b234e91c4585d853f2f6d
monotouch-9.2.0.93_1a6b88f2b2305d50bad065ae4c7292ab6348ff60

For Now I am changing the status to REOPEN As I have followed the steps mentioned in comment https://bugzilla.xamarin.com/show_bug.cgi?id=34902#c9 

Please let me know I am missing anything
Comment 21 Guillaume 2015-10-22 11:05:05 UTC
@Adrian Thanks for the workaround. I have been able to properly build my application in Release and AppStore versions and in both case to properly generate an IPA file.

I found some other issues I am going to report in separate bugs:
  - I got some errors like 'Could not strip assembly `/Users/MyUser/Library/Caches/Xamarin/mtbs/builds/MyProject/3d36846ab4eb62d2eae36bab1d80ebb9/obj/iPhone/Release/mtouch-cache/32/Build/Mono.CSharp.dll`' on switching between configurations.
  Subsequent builds, even without cleaning my setup (delete local bin/obj and mtbs folder on mac), do not failed with those errors and properly succeed.
  - I also have another issue with assemblies copied to my home directory on the mac.

Thanks again for the quick fix!
Comment 22 Akhilesh kumar 2015-10-23 11:53:48 UTC
I have checked this issue with master builds and I am successfully able to build iOS application remotely the msbuild command. 

I have followed below steps:

1. Create a unified iPhone Single View Application
2. In project options:
3. Enable IPA generation for configs Realease/iPhone & AppStore/iPhone
4. Assign a proper application identifier in order to allow build
5. Close Visual Studio and open a Visual Studio Developer Command Prompt
6. Run msbuild command to build the application

I am successfully able to build application without any error/warning.

http://screencast.com/t/nP6ZCMTm

Hence closing this issue.

XVS 99.0.0.427
XI 9.3.0.178
Comment 23 Akhilesh kumar 2015-10-27 07:23:36 UTC
I have checked this issue with latest C6 builds and observing this is working fine. I am successfully able to build iOS application remotely the msbuild command without any error/warning.

I have used  steps mentioned in Comment 22 and run below commands:

1#
C:\Program Files (x86)\Microsoft Visual Studio 14.0>msbuild "C:\Users\akhileshk\
Documents\Visual Studio 2015\Projects\TestRelease\TestRelease\TestRelease.csproj
" /p:Configuration=Release /p:ServerAddress=192.168.3.26 /p:ServerUser=Apple /p:
Platform=iPhone /p:ServerPassword=360logica

2#
C:\Program Files (x86)\Microsoft Visual Studio 14.0>msbuild "C:\Users\akhileshk\
Documents\Visual Studio 2015\Projects\TestAppStore\TestAppStore\TestAppStore.csp
roj" /p:Configuration=AppStore /p:ServerAddress=192.168.3.26 /p:ServerUser=Apple
 /p:Platform=iPhone /p:ServerPassword=360logica

Environment info:
Microsoft Visual Studio Enterprise 2015
Version 14.0.23107.0 D14REL
Microsoft .NET Framework
Version 4.6.00081

Xamarin   4.0.0.1633 (068946a)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   6.0.0.22 (cc43529)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   9.2.1.0 (4cebfec)
Visual Studio extension to enable development for Xamarin.iOS.

*********************************

Xamarin.iOS
Version: 9.2.1.9 (Business Edition)
Hash: ee9fa3f
Branch: master
Build date: 2015-10-26 23:57:04-0400

Apple Developer Tools
Xcode 7.0 (8227)
Build 7A220

Runtime:
 Mono 4.2.1 (explicit/b50293b)
 GTK+ 2.24.23 (Raleigh theme)
 Package version: 402010075
Comment 24 xamarin-release-manager 2015-11-26 10:39:52 UTC
Fixed in version 4.0.1.1 (cycle6)

Author: Adrian Alonso
Commit: cc11aaa5abb689daac7c6c2b5ab2fe63f5e338f7 (xamarin/XamarinVS)