Skip to content
Rolf Bjarne Kvinge edited this page Aug 5, 2021 · 6 revisions

Sample projects

Sample projects can be found here: https://github.com/dotnet/maui-samples.

The sample project repository also contains instructions for how to install the latest preview versions.

Creating new projects

You can create a new project by executing "dotnet new" (this will create a new macOS (Cocoa) project):

dotnet new macos

Choosing the runtime

For macOS, it's possible to choose which runtime to use, either MonoVM or CoreCLR.

The default is currently MonoVM, but you can switch to CoreCLR by adding the following to your project file:

<PropertyGroup>
    <UseMonoRuntime>false</UseMonoRuntime>
</PropertyGroup>

Issues / bugs / feature requests

If you run into any bugs, please file them here: https://github.com/xamarin/xamarin-macios/issues/new. For any kind of build problems, it's particularly helpful to get the binlog of the build. When building from the command line, you can generate a binlog by appending /bl to the command:

dotnet build /bl

An msbuild.binlog file will be created, and please attach it to any issue you open.

Use a daily/prerelease version

  1. Find the package for the version you want to try.

    Every commit will create packages, which means that you can try whichever commit you want (assuming the commit in question actually builds, and that enough time has passed for build to complete - it usually takes 8-12 hours).

    1. Go to the commit in question, so for the hash fa5f323c88e6fc0441a0f282dfbc9006a5467c5d, go to https://github.com/xamarin/xamarin-macios/commit/fa5f323c88e6fc0441a0f282dfbc9006a5467c5d.
    2. Scroll down until you see a comment that says "Packages generated". Expand the "View packages" text, and download the "Microsoft..Bundle..pkg (notarized)" link.

    If the commit in question doesn't have packages (for whatever reason), you can always look at the parent commit.

  2. Identify the .NET version this package was built with.

    This might not be required, if you have a close .NET version installed already it might work, but we recommend using the exact same version. There are often breaking changes that require a matching .NET install.

    1. Go to the eng/Version.Details.xml file for the commit in question, and get the Microsoft.Dotnet.Sdk.Internal version.

    2. Example for the commit from above: https://github.com/xamarin/xamarin-macios/blob/fa5f323c88e6fc0441a0f282dfbc9006a5467c5d/eng/Version.Details.xml#L3

    3. Download the package for the .NET version in question and install it. This is a bit complicated, but it usually works to get the link for a similar version, and change just change the version in the URL.

      For example:

      https://dotnetcli.azureedge.net/dotnet/Sdk/6.0.100-<version>/dotnet-sdk-6.0.100-<version>-osx-x64.pkg

      to

      https://dotnetcli.azureedge.net/dotnet/Sdk/6.0.100-6.0.100-rc.1.21402.7/dotnet-sdk-6.0.100-6.0.100-rc.1.21402.7-osx-x64.pkg

  3. Add a NuGet.config to your project directory with the following contents:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <packageSources>
        <add key="xamarin-impl" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/xamarin-impl/nuget/v3/index.json" />
      </packageSources>
    </configuration>

    This is required because daily/prerelease versions aren't published to nuget.org.

    Note: if you already have a NuGet.config, you'll have to add the xamarin-impl package source instead of replacing the existing one.

  4. Install the package from step 1 and corresponding workload.

    1. Install the downloaded pkg from step 1 above (this has to be done after installing .NET in step 2).

    2. Install the workload:

      Execute:

      sudo dotnet workload install <platform> --skip-manifest-update # platform = `ios`, `tvos`, `maccatalyst` or `macOS`

      The --skip-manifest-update argument is important, otherwise .NET will update the manifests to the official ones, and you'll end up installing the official versions.

  5. Add a global.json

    Add a global.json with the following content:

    {
    	"sdk": {
    		"version": "<.NET version from step #2>"
    	}
    }

    for example:

    {
    	"sdk": {
    		"version": "6.0.100-preview.7.21330.1"
    	}
    }
  6. Build your project!

    dotnet build /bl

If there are any problems, please file an issue and include the binlog file.

Clone this wiki locally