How can I build a Xamarin iOS app using MSBuild? - msbuild

I have an iOS App project, builds fine in Visual Studio (paired with my Mac build host). I want to build this project using an MSBuild command, so that I can use Teamcity for my builds. (My build agent is a Windows machine which will pair with a Mac build host).
Currently I run the following command:
msbuild MyApp.App.iOS.csproj /t:_RemoteBuild /p:ServerAddress=macmini2.local;Configuration="Debug";Platform="iPhoneSimulator";OutputPath="C:\Projects\MySolution\MyApp.App.iOS\bin\iPhoneSimulator\Debug"
And this builds my 2 library projects, but it seems to fail when building my main project:
_GenerateBundleContentDir:
Preparing application bundle
Copying file from "C:\Projects\MySolution\MyApp.App.iOS\bin\iPhoneSimulator\Debug\MyApp.Business.Core.dll" to "C:\Projects\MySolution\MyApp.App.iOS\obj\iPhoneSimulator\Debug\build_package\assemblies\MyApp.Business.Core.dll".
Copying file from "C:\Projects\MySolution\MyApp.App.iOS\bin\iPhoneSimulator\Debug\MyApp.Business.Core.pdb" to "C:\Projects\MySolution\MyApp.App.iOS\obj\iPhoneSimulator\Debug\build_package\assemblies\MyApp.Business.Core.pdb".
Copying file from "C:\Projects\MySolution\MyApp.App.iOS\bin\iPhoneSimulator\Debug\MyApp.Business.Core.dll.mdb" to "C:\Projects\MySolution\MyApp.App.iOS\obj\iPhoneSimulator\Debug\build_package\assemblies\MyApp.Business.Core.dll.mdb".
Copying file from "C:\Projects\MySolution\MyApp.App.iOS\bin\iPhoneSimulator\Debug\MyApp.Business.iOS.dll" to "C:\Projects\MySolution\MyApp.App.iOS\obj\iPhoneSimulator\Debug\build_package\assemblies\MyApp.Business.iOS.dll".
Copying file from "C:\Projects\MySolution\MyApp.App.iOS\bin\iPhoneSimulator\Debug\MyApp.Business.iOS.pdb" to "C:\Projects\MySolution\MyApp.App.iOS\obj\iPhoneSimulator\Debug\build_package\assemblies\MyApp.Business.iOS.pdb".
Copying file from "C:\Projects\MySolution\MyApp.App.iOS\bin\iPhoneSimulator\Debug\MyApp.Business.iOS.dll.mdb" to "C:\Projects\MySolution\MyApp.App.iOS\obj\iPhoneSimulator\Debug\build_package\assemblies\MyApp.Business.iOS.dll.mdb".
C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(195,3): error MSB3030: Could not copy the file "C:\Projects\MySolution\MyApp.App.iOS\bin\iPhoneSimulator\Debug\MyAppAppiOS.exe" because it was not found. [C:\Projects\MySolution\MyApp.App.iOS\MyApp.App.iOS.csproj]

At the moment it is not possible to build Xamarin.iOS projects using msbuild (it is being worked on and in the future (not sure when) this will change).
However it seems it's possible to delegate the work to the Mac: http://forums.xamarin.com/discussion/comment/44484/#Comment_44484

Related

The .csproj not able to copy .json files on Linux and macOS build servers after using Visual Studio 2019

I have ASP.NET Core 2.2 app and I've been developing with VS2017, when I started using VS2019 the first thing that happened was the sln stopped building with error pointing to my .csproj files, for example
Severity Code Description Project File Line Suppression State
Error NETSDK1022 Duplicate 'Content' items were included. The .NET SDK includes 'Content' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultContentItems' property to 'false' if you want to explicitly include them in your project file. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: 'plugin.json' ForkMeRibbon C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets 316
The cause is that in my csprojs I have certain .json files I need to be included at build time, so I have these lines in my .csproj file like below which worked fine with VS2017, but VS2019 complains. After I deleted these lines and everything worked in VS2019.
<ItemGroup>
<Content Include="plugin.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
Then however after I checked my code into github, the build servers of Azure Pipeline, AppVeyor and Travis CI are not happy, they complain that my "plugin.json" file is not found. After some struggling, I was able to fix the build for AppVeyor by changing image: Visual Studio 2017 to image: Visual Studio 2019 in the yml file.
It seems like the build servers are configured with VS2017-ish configurations, unless you tell it to use VS2019 compatible configurations it will not copy over my json file thus causing errors. So far all Windows builds are fine, but the Linux and macOS builds on Azure Pipeline and Travis CI are not, for example here is a failed build on Travis, and message error MSB3030: Could not copy the file "bin/Debug/netcoreapp2.2/plugin.json" because it was not found.
Has anyone else run into this issue and how did you solve it?

MSBuild GenerateResource task produces resource file names with incomplete namespace, causing our app to crash at runtime

We build mobile apps using Xamarin Forms, with macOS building the iOS apps. We ran into an issue today that has left me scratching my head.
A normal build with embedded resource files looks like this:
CoreResGen:
/Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/4.5/resgen.exe /useSourcePath
[....all of our references....]
/compile
Resources/HtmlStyleRes.resx,obj/BuildAgentRelease_iOS/ForumApp.Common.Resources.HtmlStyleRes.resources
Resources/TextRes.resx,obj/BuildAgentRelease_iOS/ForumApp.Common.Resources.TextRes.resources
Resources/TextRes.nb.resx,obj/BuildAgentRelease_iOS/ForumApp.Common.Resources.TextRes.nb.resources
So no surprises there; the .resx files are compiled into binary .resources files with the assembly namespace + folder name + resx filename.
However, we made a change to our directory structure on the build server, and this changed the output from CoreResGen:
CoreResGen:
/Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/4.5/resgen.exe /useSourcePath
[....all of our references....]
/compile
Resources/HtmlStyleRes.resx,obj/BuildAgentRelease_iOS/ForumApp.Common.HtmlStyleRes.resources
Resources/TextRes.resx,obj/BuildAgentRelease_iOS/ForumApp.Common.TextRes.resources
Resources/TextRes.nb.resx,obj/BuildAgentRelease_iOS/ForumApp.Common.TextRes.nb.resources
Notice how the "Resources" folder was dropped from the .resources filename. When compiled into an app, this causes our app to crash at runtime, since the resource file namespace is now different.
We build our apps using self-hosted Azure agents. All apps are built from the same repository, and as part of an effort to streamline the build servers, we implemented a pipeline task to utilize a common repository folder for all builds. The Azure agent would normally build out of _work/build-id/s, and our pipeline task will symlink this directory to _work/g/repo-id so that multiple builds can share the same repository.
When we build with the repo in _work/build-id/s, everything is fine. When we build with the symlinked repo, the file namespace error occurs.
As far as we can tell, this happens on macOS, but not on Windows.
We have a possibly related issue that happens on macOS, but not on Windows. The following outputs are from macOS using mono:
Path.GetDirectoryName(#"Resources\TextRes.resx") => ""
Path.GetDirectoryName(#"Resources/TextRes.resx") => "Resources"
Path.GetDirectoryName is used in CreateCSharpManifestResourceName to create the output file name from Resources\TextRes.resx, but there appear to be guards replacing \ with / and I can't see why symlinking the source folder would trigger it.
Has anyone experienced this? Am I missing something obvious?

How to import the openjdk9 source code to visual studio 2017 after compilation in Windows 10l?

I tried to build the openjdk9 source code in Windows 10 by the following commands
go to D:\jdk9\jdk9 with cygwin
./configure -with-freetype=/cygdrive/c/freetype -enable-debug -with-target-bits=64
make all
Finally it build successfully with messages :
Creating support/demos/image/jfc/Font2DTest/Font2DTest.jar
Creating support/demos/image/jfc/Metalworks/Metalworks.jar
Creating support/demos/image/jfc/Notepad/Notepad.jar
Creating support/demos/image/jfc/TableExample/TableExample.jar
Creating support/demos/image/jfc/TransparentRuler/TransparentRuler.jar
Creating support/demos/image/jfc/SampleTree/SampleTree.jar
Creating jre jimage
Creating jdk jimage
WARNING: Using incubator modules: jdk.incubator.httpclient
WARNING: Using incubator modules: jdk.incubator.httpclient
Finished building target 'all' in configuration 'windows-x86_64-normal-server-fastdebug'
However how to import the project such as jdk or Hotspot to visual studio? There is neither no solution file nor project file generated, also there is no create.bat file exist in folder \jdk9\hotspot\make (openjdk 8 has the file), so how to import the jdk/Hotspot source code to the visual studio 2017 to debug the source code?
To build VS Project Creator run the following command from the openjdk9 top directory:
make hotspot-ide-project
In my case, the generated VS project files are located in:
.../openjdk9/build/windows-x86_64-normal-server-slowdebug/ide/hotspot-visualstudio
Finally, find the jvm.vcxproj file in the hotspot-visualstudio directory and open it.

TFS 2012 - binary files are not generated when using automatic build

I am newbie to TFS.
I am trying to automate process of build upon checking in the code in TFS.
I setup a Controller and an Agent. I created a new build definition and set a "build" and "drop" folder on c:.
I check in the code, expecting to see the generated dll files in "drop" folders. There's none, just "logs" folder. The "binaries" folder in "build" folder is also empty. Apparently the binaries are not being generated at all. How can I have MSBuild to generate the dll files?
They are generated when I compile the website locally on my development machine under "bin\" folder. The solution is comprised of two separate projects: "core" and "web" where "core" is referenced within "web".
Any thoughts?
What is the Summary showing of your build that ran? Or are there errors in your build? You can check the log of the build by opening the build in Visual Studio and then click View Log.

Teambuild not copying XAP fiesl to _PublishedWebsites

I have a TFS build for sivelright and it copies all the files in the web project to _PublishedWebsites, except the xap file. Error is
Web.csproj error MSB3021: Unable to copy file "Some.xap" to "c:\somewhere\Some.xap" Could not find file "Some.xap".
What it is trying to do, from where it is trying to copy and why it is failing?
Make sure your projects are built in the right order in your TFS Build Definition (Build Definition, Process, Required, Project to Build).