Skip to content

Commit c156c28

Browse files
Updated Migration document for 3.8.x upgrade
1 parent 196364a commit c156c28

File tree

1 file changed

+87
-41
lines changed

1 file changed

+87
-41
lines changed

articles/migration/migrate_38.md

Lines changed: 87 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,119 @@
11
---
2-
title: Migrating from 3.8.0
3-
description: A guide on migrating a MonoGame v3.8.0 project to the current version of MonoGame.
2+
title: Migrating from 3.8.0 or later to 3.8.4.1
3+
description: A guide on migrating a MonoGame v3.8 project to the current 3.8.4 version of MonoGame.
44
---
55

6-
Migrating from 3.8.0 should be straightforward for most platforms.
6+
Migrating from earlier 3.8 releases should be straightforward for most platforms.
77

8-
The major difference is that 3.8.1 now requires .NET 6 and Visual Studio 2022. You can follow the [environment setup tutorial](../getting_started/index.md) to make sure that you are not missing any components.
8+
The major difference is that 3.8.4 onward recommends using .NET 9 in your client project (mandatory for Mobile projects by the DotNet Framework). You can follow the [environment setup tutorial](../getting_started/index.md) to make sure that you are not missing any components.
99

10-
The MGCB Editor is no longer a global .NET tool and we recommend that you use the new Visual Studio 2022 extension which helps with accessing it without the need of CLI commands.
10+
The MGCB Editor is no longer a global .NET tool and the MGCB editor is included as part of the specific project through the use of the dotnet tooling configuration `dotnet-tools.json` file located in the `.config` folder in your solution/project.
1111

1212
> [!NOTE]
13+
> If you are using Visual Studio 2022, we recommend that you use the MonoGame extension which helps with accessing the MGCB editor without the need of CLI commands.
14+
15+
The process of updating your project should be fairly quick and painless without having to change your code or your content project.
16+
17+
> [!IMPORTANT]
1318
> It is also recommended that you uninstall the older global versions of the .NET tools as described below.
1419
15-
## WindowsDX, DesktopGL, and UWP
20+
## Contents
1621

17-
Upgrading from 3.8.0 should be as straightforward as upgrading your ```TargetFramework``` and MonoGame version.
22+
- [Updating DotNet Target Framework](#updating-dotnet-target-framework)
23+
- [Update MonoGame references](#update-monogame-references)
24+
- [Add/Update `dotnet-tools.json` Configuration](#addupdate-dotnet-toolsjson-configuration)
25+
- [Remove `RestoreDotnetTools` section from csproj](#remove-restoredotnettools-section-from-csproj)
26+
- [iOS/iPadOS, and Android Considerations](#iosipados-and-android-considerations)
1827

19-
Edit your csproj file to change your ```TargetFramework```:
28+
## Updating DotNet Target Framework
2029

21-
```xml
22-
<TargetFramework>net6.0</TargetFramework>
23-
```
30+
Modern MonoGame projects now use the DotNet framework (older project used to rely on the NetCore/NetFramework libraries). As MonoGame has used DotNet project templates since 3.8.x, you only need to replace the `TargetFramework` element of any `csproj` files referencing MonoGame libraries, namely:
2431

25-
Then edit your MonoGame ```PackageReference``` to point to 3.8.1:
32+
- Replace any `<TargetFramework>` entries to the following:
2633

2734
```xml
28-
<PackageReference Include="MonoGame.Framework.{Platform}" Version="3.8.1.*" />
29-
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.*" />
35+
<TargetFramework>net9.0</TargetFramework>
3036
```
3137

32-
### Accessing MGCB and MCGB Editor without a global tool
38+
> [!NOTE]
39+
> Using `DotNet 9` is only a **recommendation**, you can use any version of DotNet (from 8.0 and above) so long as it supports the MonoGame Dotnet 8 dependency. This includes the upcoming DotNet 10 LTS.
3340
34-
The MGCB Editor is no longer a .NET global tool, and does not need to be installed or registered. When migrating from 3.8.0, it is recommended that you **uninstall** the global versions of the tools. You can accomplish that with these commands:
41+
Make sure to update any and all projects in your solution, especially you have a multi-project solution similar to those in the [MonoGame.Samples](https://github.com/MonoGame/MonoGame.Samples/tree/3.8.4/Platformer2D)
3542

36-
```sh
37-
dotnet tool uninstall dotnet-mgcb -g
38-
dotnet tool uninstall dotnet-2mgfx -g
39-
dotnet tool uninstall dotnet-mgcb-editor -g
40-
```
43+
## Update MonoGame references
44+
45+
Ensure you update the MonoGame references to the latest version, this can be achieved by either:
46+
47+
- Editing the `csproj` files that reference MonoGame to the latest version
48+
49+
> [!NOTE]
50+
> The MonoGame templates set the Version number as `Version="3.8.*"`, this means that it will use the LATEST public version of MonoGame (not including preview releases) that is available. However, this does mean your `tools` configuration can become out of sync with your project and potentially cause issue.
51+
52+
- Use the [Updating NuGet package dependencies](../getting_to_know/howto/HowTo_Install_Preview_Release.md#updating-nuget-package-dependencies) documentation as part of the "Preview Release installation instructions", which states you just need to run the following commands (for `DesktopGL`, use other platforms accordingly):
53+
54+
```dotnetcli
55+
dotnet add package MonoGame.Framework.DesktopGL -v 3.8.4.1
56+
dotnet add package MonoGame.Content.Builder.Task -v 3.8.4.1
57+
```
4158
42-
::: tip
43-
**Do not** run the ``` dotnet tool install ``` on 3.8.1, as it would break 3.8.1.
44-
:::
59+
> [!NOTE]
60+
> The `MonoGame.Content.Builder.Task` is only needed for client projects and not libraries.
4561
46-
You will also need to setup a dotnet-tools configuration file.
62+
This will ensure your project is using the intended version of MonoGame.
4763
48-
- Next to your ```.csproj```create a folder named ```.config```
49-
- Add a file within the folder named ```dotnet-tools.json``` with the following content:
64+
> [!IMPORTANT]
65+
> Always ensure your `dotnet-tools.json` version matches any updates to the version of MonoGame you are using, see next section.
5066
51-
```json
67+
## Add/Update `dotnet-tools.json` Configuration
68+
69+
MonoGame DotNet projects currently **Require** DotNet tools configuration to be able to locate and run the `MGCB` editor which is installed locally per project (preventing issues when working with multiple projects using different versions of MonoGame).
70+
71+
> [!IMPORTANT]
72+
> The MGCB Editor is no longer a .NET global tool, and does not need to be installed or registered. When migrating from 3.8.0, it is recommended that you **uninstall** the global versions of the tools. You can accomplish that with these commands:
73+
>
74+
> ```sh
75+
> dotnet tool uninstall dotnet-mgcb -g
76+
> dotnet tool uninstall dotnet-2mgfx -g
77+
> dotnet tool uninstall dotnet-mgcb-editor -g
78+
> ```
79+
80+
You can either copy the configuration from a new project template (e.g. `dotnet new mgdesktopgl -o <project name>`),
81+
alternatively you can do the following:
82+
83+
- Create a new folder in the root of your project named `.config`
84+
- Add a new file called `dotnet-tools.json` and replace its contents with the following:
85+
86+
```text
5287
{
5388
"version": 1,
5489
"isRoot": true,
5590
"tools": {
5691
"dotnet-mgcb": {
57-
"version": "3.8.1.303",
92+
"version": "3.8.4.1",
5893
"commands": [
5994
"mgcb"
6095
]
6196
},
6297
"dotnet-mgcb-editor": {
63-
"version": "3.8.1.303",
98+
"version": "3.8.4.1",
6499
"commands": [
65100
"mgcb-editor"
66101
]
67102
},
68103
"dotnet-mgcb-editor-linux": {
69-
"version": "3.8.1.303",
104+
"version": "3.8.4.1",
70105
"commands": [
71106
"mgcb-editor-linux"
72107
]
73108
},
74109
"dotnet-mgcb-editor-windows": {
75-
"version": "3.8.1.303",
110+
"version": "3.8.4.1",
76111
"commands": [
77112
"mgcb-editor-windows"
78113
]
79114
},
80115
"dotnet-mgcb-editor-mac": {
81-
"version": "3.8.1.303",
116+
"version": "3.8.4.1",
82117
"commands": [
83118
"mgcb-editor-mac"
84119
]
@@ -87,23 +122,34 @@ You will also need to setup a dotnet-tools configuration file.
87122
}
88123
```
89124

90-
Please note that you cannot use the ```3.8.1.*``` wildcard in the ```dotnet-tools.json``` file (tool versions have to be fully qualified). We strongly recommand that the versions match the MonoGame version referenced in your ```.csproj``` (if you are using the ```*``` wildcard, make sure that they do not end up mismatching if the nugets are updated without you noticing).
125+
> [!NOTE]
126+
> Please note that you cannot use the ```3.8.*``` wildcard in the ```dotnet-tools.json``` file (tool versions have to be fully qualified). We strongly recommand that the versions match the MonoGame version referenced in your ```.csproj``` (if you are using the ```*``` wildcard, make sure that they do not end up mismatching if the nuget's are updated without you noticing).
91127
92-
You will also need to add this to your ```.csproj```:
128+
The file is the same regardless of which platform / target you are intending to use. If you have a solution, you only need a **SINGLE** configuration at the root of the project for all client projects.
129+
130+
## Remove `RestoreDotnetTools` section from csproj
131+
132+
From `3.8.4.1` and above, the `RestoreDotnetTools` section is no longer required in client project `csproj` files, as the processing is now handled within the MonoGame deliverables.
133+
134+
> [!NOTE]
135+
> Earlier versions of MonoGame, e.g. 3.8.0 does not have this configuration in the project template, if your `csproj` does not have a `RestoreDotnetTools` element, you can safely ignore this section.
93136
94137
```xml
95-
<Target Name="RestoreDotnetTools" BeforeTargets="CollectPackageReferences">
138+
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
96139
<Message Text="Restoring dotnet tools" Importance="High" />
97140
<Exec Command="dotnet tool restore" />
98141
</Target>
99142
```
100143

101-
With these changes, .NET will automatically install the MGCB Editor for you when launching Visual Studio 2022 (if you want to install it manually and skip adding the Target, run ```dotnet tool restore``` within the project directory).
144+
> [!NOTE]
145+
> The XML has changed over versions with various messages and layout, but the section to remove is always titled `Name="RestoreDotnetTools"`
102146
103-
Then, if you installed the Visual Studio extension, you should also be able to just double-click an ```.mgcb``` file to open the MGCB Editor. You can also open the MGCB Editor with the CLI via ```dotnet mgcb-editor``` when executed from within the project directory.
147+
Simply remove this section safely from any and all `csproj` files located in your solution that are dependent on MonoGame.
104148

105-
This new configuration has the advantage of allowing to have per-project versions of MGCB and its Editor (instead of per-machine like a global tool).
149+
## iOS/iPadOS, and Android Considerations
106150

107-
## iOS/iPadOS, and Android
151+
DotNet 9 is MANDATORY for iOS and Android due to platform requirements, as well as the following configurations:
108152

109-
.NET 6 introduced breaking changes in how csproj are defined for iOS/iPadOS and Android. We recommand that you create new projects using the 3.8.1 templates and that you copy over your project files there.
153+
- MonoGame 3.8.4.1 is **REQUIRED** to comply with the Google Policies on 16kb pages and other affordances.
154+
- The Android `targetSdkVersion` in the `AndroidManifest.xml` **MUST** be a minimum "35" to comply with the latest Google policies.
155+
- iOS **MUST** use a minimum `SupportedOSPlatformVersion` of `12.2` in both the `csproj` and in the `info.plist` configuration for the project.

0 commit comments

Comments
 (0)