MonoGame in Visual Studio Code

The application does compile + runs fine, but I can’t guarantee that everything is feature complete. I still have to evaluate the boundaries.

Running MonoGame 3.7.0.7 on Ubuntu 18.10
Running MonoGame 3.7.0.7 on Ubuntu 18.10

Linux

Create a new project by typing following command in the Visual Studio Code Terminal: “dotnet new console”. Open the “.csproj” and paste in following XML.

<?xml version="1.0" encoding="UTF-8"?>
<Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
      <OutputType>Exe</OutputType>
      <TargetFramework>netcoreapp2.1</TargetFramework>
   </PropertyGroup>
   <ItemGroup>
      <SrcFolderReference Include="**\*.cs" />
   </ItemGroup>
   <ItemGroup>
      <MonoGameContentReference Include="**\*.mgcb" />
   </ItemGroup>
   <ItemGroup>
      <PackageReference Include="MonoGame.Content.Builder" Version="3.7.0.4" />
      <PackageReference Include="MonoGame.Framework.DesktopGL.Core" Version="3.7.0.7" />
   </ItemGroup>
</Project>

The NuGet Package Manager plugin should automatically download all the required dependencies. Generate a new launch configuration: Debug -> Add Configuration. Open the launch.config in the .vscode folder and paste following snippet.

{
    // Use IntelliSense to find out which attributes exist for C# debugging
    // Use hover for the description of the existing attributes
    // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
    "version": "0.2.0",
    "configurations": [
         {
             "name": ".NET Core Client",
             "type": "coreclr",
             "request": "launch",
             "preLaunchTask": "Build Client",
             // If you have changed target frameworks, make sure to update the program path.
             "program": "${workspaceFolder}/ToDo/bin/Debug/netcoreapp2.1/ToDo.dll",
             "args": [],
             "cwd": "${workspaceFolder}/ToDo/",
             // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
             "console": "integratedTerminal",
             "internalConsoleOptions":"openOnFirstSessionStart",
             "justMyCode": true,            
             "stopAtEntry": false,
         }
 }

“program” refers to the compiled library. In my case, I have following project structure.

  • .vscode
  • ToDo
    • bin
      • Debug
        • ….

Add a new build configuration: Terminal -> Configure Tasks. Open the generated tasks.json in the .vscode folder and paste in following snippet

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Build Client",
      "command": "dotnet",
      "type": "process",
      "args": [
        "build",
        "${workspaceFolder}/ToDo/ToDo.csproj"
      ],
      "problemMatcher": "$msCompile"
    }
  ]
}

Here you go. You are ready to build and run. Have fun.

Windows

An example of windows can be found here. (Source: Andrew King)

0 0 vote
Article Rating
Subscribe
Notify of
2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Andrzej Jóźwiak

Could you advise me how to setup mgcb? From the screenshot I noticed that the tool is showing for you and is building resources.