Update project 3.7 to 3.8

Hello, I am trying to update a project created with MonoGame 3.7 and VS2019 on a computer without MonoGame 3.7 installed.

I have followed the instructions in:
https://docs.monogame.net/articles/migrate_37.html

But I can’t get it to work. I can open the project, but it seems that the namespace “Microsft.Xna” does not exist. And MonoGame packages appear in the project reference list.

I have no idea how to fix it. Is it necessary to install MonoGame 7.1 in order to update the project?

Thank you.

1 Like

Hi @Barri_soft and Welcome to the Community!

Have you tried renaming it to Monogame? also use NUGET to add the references…

Hopefully, someone can quickly visit and assist, having to do a refresh again…

I wonder if it helps if you mention your project type/platform targets…

Happy Coding!

Are you able to create and run a MonoGame 3.8 project before adding your existing code? As MrValentine asked how are you referencing MonoGame 3.8? Is your project targeting .NET Core 3.1? You shouldn’t need MonoGame 3.7.1 installed in order to upgrade. Instead of copying your .csproj files over try creating a new project and copying and pasting the code and content or use add existing item to add them.

1 Like

Thank you very much for the answers.

The type of project was created with version 3.7 “MonoGame Windows Project” on .Net Framework 4.5.

Yes, I can create and run new 3.8 projects.
I can use this option to create new projects and move the code, but I have a few projects and I prefer to find a better solution.

Any other ideas?

We can only make guesses at what’s wrong unless you show us the contents of your .csproj file.

For games I had to change the TargetFramework in the .csproj to netcoreapp3.1 because 3.8 targets .NET Core 3.1. In libraries you might need netstandard2.0. Without seeing the .csproj it’s hard to say what else needs to be changed.

The file after the changes is:

<?xml version="1.0" encoding="utf-8"?> Debug x86 8.0.30703 2.0 {C7D7F6D5-DF70-49F0-9361-F5422D76918C} WinExe Properties Pong Pong 512 Windows v4.5 x86 true full false bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ DEBUG;TRACE;WINDOWS prompt 4 x86 pdbonly true bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ TRACE;WINDOWS prompt 4 Icon.ico app.manifest

That is not readable. Please format your post with code tags https://www.markdownguide.org/extended-syntax/#fenced-code-blocks

The csproj file after changes:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
    <ProductVersion>8.0.30703</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{C7D7F6D5-DF70-49F0-9361-F5422D76918C}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>Pong</RootNamespace>
    <AssemblyName>Pong</AssemblyName>
    <FileAlignment>512</FileAlignment>
    <MonoGamePlatform>Windows</MonoGamePlatform>
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <PlatformTarget>x86</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\</OutputPath>
    <DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
    <PlatformTarget>x86</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\</OutputPath>
    <DefineConstants>TRACE;WINDOWS</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup>
    <ApplicationIcon>Icon.ico</ApplicationIcon>
  </PropertyGroup>
  <PropertyGroup>
    <ApplicationManifest>app.manifest</ApplicationManifest>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="Base\Game1_Base.cs" />
    <Compile Include="Pong_0\Game_Pong_0.cs" />
    <Compile Include="Pong_1\Game_Pong_1.cs" />
    <Compile Include="Pong_2\Game_Pong_2.cs" />
    <Compile Include="Pong_3\Game_Pong_3.cs" />
    <Compile Include="Pong_3\Pelota.cs" />
    <Compile Include="Pong_3\Raqueta.cs" />
    <Compile Include="Pong_4\Game_Pong_4.cs" />
    <Compile Include="Pong_4\Pelota.cs" />
    <Compile Include="Pong_4\Raqueta.cs" />
    <Compile Include="Pong_5\Game_Pong_5.cs" />
    <Compile Include="Pong_5\Pelota.cs" />
    <Compile Include="Pong_5\Raqueta.cs" />
    <Compile Include="Pong_6\Game_Pong_6.cs" />
    <Compile Include="Pong_6\Pelota.cs" />
    <Compile Include="Pong_6\Raqueta.cs" />
    <Compile Include="Pong_7\Game_Pong_7.cs" />
    <Compile Include="Pong_7\Pelota.cs" />
    <Compile Include="Pong_7\Raqueta.cs" />
    <Compile Include="Pong_8\Game_Pong_8.cs" />
    <Compile Include="Pong_8\Pelota.cs" />
    <Compile Include="Pong_8\Raqueta.cs" />
    <Compile Include="Pong_9\Game_Pong_9.cs" />
    <Compile Include="Pong_9\Pelota.cs" />
    <Compile Include="Pong_9\Raqueta.cs" />
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="Icon.ico" />
  </ItemGroup>
  <ItemGroup>
    <MonoGameContentReference Include="Content\Content.mgcb" />
    <None Include="app.manifest" />
  </ItemGroup>
  <ItemGroup />
  <ItemGroup>
    <PackageReference Include="MonoGame.Framework.WindowsDX" Version="3.8.0.1641" />
    <PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

Thank You.

Try replacing that with the following:

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <PublishReadyToRun>false</PublishReadyToRun>
    <TieredCompilation>false</TieredCompilation>
  </PropertyGroup>

and delete this.

```
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <PlatformTarget>x86</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\</OutputPath>
    <DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
    <PlatformTarget>x86</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\</OutputPath>
    <DefineConstants>TRACE;WINDOWS</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>

Your csproj file uses the old outdated csproj format instead of the SDK format. You should consider creating a new csproj file from the monogame 3.8 template and just add your files in manually. You don’t have a lot of files so it shouldn’t take that long

Thank you very much, but it doesn’t work. Now when opening the project it gives an error: Visual Studio has had an unexpected problem that can affect some functions of the project system.

I think it’s a waste of time to keep trying to update my projects from 3.7 to 3.8. Especially because of my low level with Visual Studio and MonoGame.

I will be updating my projects with new .Net Core and MonoGame 3.8 projects.

Indeed, the Pong project does not have many files, but I have a few projects and it would be nice to be able to update them simply and quickly.

Thank you all for the interest shown in my problem.
It is a pleasure to belong to the MonoGame family.

I wish there is more I could do to help you. There isn’t an easy way to do it. The architecture between the two projects is different. I’ve had to do it manually for all my projects by creating new projects and copy/pasting the files/content. It’s a pain and time consuming. I’m going to do some tests and try and make a migration tool.

I often find, going through a project can shine light on things that could be implemented better…

Thanks Synammon, it would be great to have a migration tool. It would help beginners like me a lot. Above all, considering the number of examples and projects on the Internet for MonoGame 3.7.

Despite these migration issues, I think MonoGame 3.8 is a breakthrough. Congratulations to the development team.

To be honest, the best migration path with MonoGame 3.8 in my experience is simply to create the different MR projects your solution needs and just copy over the code.

Far easier in my experience, especially after updating all the MonoGame.Samples projects and a dozen other samples. You can simply get lost in the differences moving from a VS to .NETCore project type and it is simply cleaner to move code.

Might not be for everyone, but it takes me 5 mins max per project using the above method :smiley:

2 Likes

I concur :sake:

Yea, I sort of did that with the update of my samples, new project but added the source as a linked file :slight_smile:

All new samples will be in 3.8 though :slight_smile:

1 Like