An unofficial way to keep building Xamarin Projects on Bitrise

After the deprecation of the Visual Studio for Mac stack and the Xamarin Steps on Bitrise, there is a way to keep building Xamarin projects on Bitrise. Please note that this method is not guaranteed to work for all Xamarin projects and Bitrise will not officially support these projects anymore, but it might help Xamarin users until the official MAUI release.

After the deprecation of the Visual Studio for Mac stack and the Xamarin Steps on Bitrise, there is a way to keep building Xamarin projects on Bitrise. Please note that this method is not guaranteed to work for all Xamarin projects and Bitrise will not officially support these projects anymore, but it might help Xamarin users until the official MAUI release.

Strategy

Ideally, the migration from the Visual Studio for Mac Stack should be easy and straightforward. The source code of the Xamarin steps will be available after the deprecation. Therefore, they can still be used by importing the source code directly in the bitrise.yml file (read the details here).

The Visual Studio for Mac Stack is based on an Xcode stack with Visual Studio for Mac and other related tooling installed. Our strategy will be to start from an Xcode stack and install all the tooling for building a Xamarin project.

Migration Setup

We wanted to avoid having to install the whole Visual Studio for Mac from the UI. This is why we focused on two commands that are used in the Xamarin steps: msbuild and nuget. We changed a 'Xamarin' project to be of type 'Other' so that we can choose from the standard Xcode Stacks and we copied the Xamarin build workflow. We selected the standard Xcode 12.5 stack.

After several attempts to configure the tools independently, from the command line, by installing dotnet and Mono, we were getting blocked by the required Xamarin dependencies. Then we noticed that everything that was needed to build the project was in 4 frameworks in the /Library/Frameworks directory.

Xamarin as 4 Frameworks

Our first successful attempt to build a Xamarin project on a standard Xcode stack was by downloading the following 4 frameworks

1. Mono.framework

2. Xamarin.iOS.framework

3. Xamarin.Android.framework

4. Xamarin.Mac.framework

from the Visual Studio for Mac Stack and copying them to /Library/Frameworks directory of the Xcode 12.5 Stack in a Script Step. This was sufficient to keep building.

In our experiment, we published the frameworks as a Bitrise artifact, and then we used the Bitrise API to download it. The downloading took about 2 minutes of building time. The size of the frameworks was about 1.7Gb.

Install with Homebrew

We shared the frameworks method with the community and we received some good feedback. If we could install the frameworks from the official sources, we could avoid storing them in external file storage and we could also install newer versions of Xamarin. We ended up using Homebrew Cask. We used this script from a Script Step.


brew update
brew tap homebrew/cask-versions
brew install --cask mono-mdk-for-visual-studio
brew install --cask xamarin-ios
brew install --cask xamarin-android
Copy code

It took 5.7 minutes to install the tooling.

Both ways can be used depending on whether the goal is to build fast or to be flexible with the versions. Once we’re certain that the versions won’t change, we can possibly save the frameworks to external file storage and get the best of both methods.

MAUI

MAUI is the future of Xamarin. Find more about it here.

No items found.
The Mobile DevOps Newsletter

Explore more topics

App development

Best practices from engineers on how to use Bitrise to build better apps, faster.

Community

Meet other Bitrise engineers, technology experts, power users, partners and join our BUGs.

Company

All the updates about Bitrise events, sponsorships, employees, and more.

Insights

Mobile development, latest tech, industry insights, and interviews with experts.

Mobile DevOps

Learn why mobile development is unique and requires a set of unique practices.

Releases

Stay tuned for the last updates, new features, and product improvements.

The Mobile DevOps Newsletter

Join 1000s of your peers. Sign up to receive Mobile DevOps tips, news, and best practice guides once every two weeks.