Skip to content

Commit 1d2628b

Browse files
committed
Update MacOS packaging_games.md
1 parent 0a7b299 commit 1d2628b

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

articles/getting_started/packaging_games.md

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ To publish desktop games, it is recommended that you build your project as a [se
1313

1414
From the .NET CLI:
1515

16-
`dotnet publish -c Release -r win-x64 /p:PublishReadyToRun=false /p:TieredCompilation=false --self-contained`
16+
`dotnet publish -c Release -r win-x64 -p:PublishReadyToRun=false -p:TieredCompilation=false -p:PublishAot=true --self-contained`
1717

1818
You can then zip the content of the publish folder and distribute the archive as-is.
1919

@@ -24,8 +24,12 @@ If you are targeting WindowsDX, note that players will need [the DirectX June 20
2424
From the .NET CLI:
2525

2626
```cli
27-
dotnet publish -c Release -r osx-x64 /p:PublishReadyToRun=false /p:TieredCompilation=false --self-contained
28-
dotnet publish -c Release -r osx-arm64 /p:PublishReadyToRun=false /p:TieredCompilation=false --self-contained
27+
dotnet publish -c Release -r osx-x64 -p:PublishReadyToRun=false -p:TieredCompilation=false -p:PublishAot=true --self-contained
28+
dotnet publish -c Release -r osx-arm64 -p:PublishReadyToRun=false -p:TieredCompilation=false -p:PublishAot=true --self-contained
29+
```
30+
31+
```cli
32+
lipo -create bin/Release/osx-arm64/YouGame bin/Release/osx-x64/YouGame --output bin/Release/YourGame.app/Contents/MacOS/YouGame
2933
```
3034

3135
We recommend that you distribute your game as an [application bundle](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html). Application bundles are directories with the following file structure:
@@ -37,25 +41,10 @@ YourGame.app                    (this is your root folder)
3741
            - Content           (this is where all your content and XNB's should go)
3842
            - YourGame.icns     (this is your app icon, in ICNS format)
3943
        - MacOS
40-
- amd64 (this is where your game executable for amd64 belongs, place files from the osx-x64/publish directory here)
41-
- arm64 (this is where your game executable for arm64 belongs, place files from the osx-arm64/publish directory here)
42-
- YourGame (the entry point script of your app, see bellow for contents)
44+
- YourGame (the main executable for your game)
4345
     - Info.plist            (the metadata of your app, see bellow for contents)
4446
```
4547

46-
The contents of the entry point script:
47-
48-
```sh
49-
#!/bin/bash
50-
51-
cd "$(dirname $BASH_SOURCE)/../Resources"
52-
if [[ $(uname -p) == 'arm' ]]; then
53-
./../MacOS/arm64/YourGame
54-
else
55-
./../MacOS/amd64/YourGame
56-
fi
57-
```
58-
5948
The `Info.plist` file is a standard macOS file containing metadata about your game. Here is an example file with required and recommended values set:
6049

6150
```xml
@@ -111,7 +100,7 @@ For archiving, we recommend using the .tar.gz format to preserve the execution p
111100

112101
From the .NET CLI:
113102

114-
`dotnet publish -c Release -r linux-x64 /p:PublishReadyToRun=false /p:TieredCompilation=false --self-contained`
103+
`dotnet publish -c Release -r linux-x64 -p:PublishReadyToRun=false -p:TieredCompilation=false -p:PublishAot=true --self-contained`
115104

116105
You can then archive the content of the publish folder and distribute the archive as-is.
117106

@@ -123,6 +112,22 @@ We recommend using the .tar.gz archiving format to preserve the execution permis
123112

124113
.NET proposes several parameters when publishing apps that may sound helpful, but have many issues when it comes to games (because they were never meant for games in the first place, but for small lightweight applications).
125114

115+
### PublishAot
116+
117+
This option optimises your game code "Ahead of Time". It allows you to ship your game without the need to JIT (Just In Time compile).
118+
However you do need to currently add some additional settings to your .csproj.
119+
120+
```
121+
<ItemGroup>
122+
<TrimmerRootAssembly Include="MonoGame.Framework" />
123+
<TrimmerRootAssembly Include="mscorlib" />
124+
</ItemGroup>
125+
```
126+
127+
The `TrimmerRootAssembly` stops the trimmer removing code from these assemblies. This will on the whole allow the game to run without
128+
any issues. However if you are using any Third Party assemblies, you might need to add them to this list.
129+
For MacOS it is recommended that you publish using AOT as it simplifies the app bundle.
130+
126131
### ReadyToRun (R2R)
127132

128133
[ReadyToRun](https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0#readytorun-images) is advertised as improving application startup time, but slightly increasing binary size. We recommend not using it for games, because it produces micro stutters when your game is running.

0 commit comments

Comments
 (0)