Visual Studio Code and Monogame?

I’ve just installed the new IDE from microsoft for Linux and Mac called VS Code : https://code.visualstudio.com// . How can I make monogame(on Ubuntu 14.04) run with it? Thanks!

I’ve only had the briefest play with it on Windows so far. It doesn’t use .sln or .csproj files, but rather you load a folder of files. I also think this preview does not support building or debugging C# yet. It seems to be focused on HTML5/Javascript at this stage.

For now, you will still have to use MonoDevelop 4.0, available for free in the Ubuntu Software Center.

https://code.visualstudio.com/Docs/languages#_c35

I stand corrected. Give it a try. Load the MonoGame.Framework.Linux.sln and see what it does.

Where can I find that .sln solution ? :slight_smile:

P.S: I dont have monogame 3.4 even tho I’d like to(I dont know how to install it)

I’m not familiar enough with Linux to describe how to get started from scratch. MonoGame has been designed to work with MonoDevelop, so starting out with VS Code is diving into the deep end.

You will find the Linux .zip here. It contains a generate shell script to create the installer.

Few things to note:

  1. The link provided only contains Pipeline Tool for Linux, the xs addin is installed from MonoDevelop Addin store, and the xs addin has to be built from Mac
  2. You won’t be able to run scripts without: https://github.com/mono/MonoGame/pull/3786/files I forgot to included those since it’s built on WIndows, and I’ve already had correct permissions setup for unix
  3. The day VS Code came out for Linux I played a bit with it, but I couldn’t get it to load any sln/csproj file, and yes I’ve read that part of the documentation

Right, first thing to get straight is that vs code doesn’t open sln/csproj files. As KonajuGames states it only opens folders.
If however the folder you open os the root of your project that contains an sln, then it will read that to get the list of libraries available to do basic intellisense, code peek and docs.

VS code also can’t compile or debug regular c# projects (although is does have some basic web debugging for c# / php). It is at its core, a functional text editor with syntax highlighting and git integration

Hope this helps

From the MS docs, it states that it will open a .sln or .csproj if it finds it. And it will support building and debugging C#. Just not yet available in the preview release.

Hey guys with all the new changes to VSCode and its support for Mono/.Net Core is there a way of getting it to compile and run using VSCode? I’ve been struggling to get it to work. :
I was using cra0zy’s tutorial but it seams that its a bit out of date now and also I don’t think ‘xbuild’ works on Windows…

You are probably better with Visual Studio Community Edition, is there a reason you want VSCode?

It loads faster, runs faster and is cross-platform. It has a nice clean and simple look and feel I like but yes I could probably use clunky CE.

You can use msbuild on Windows.

It probably needs updating now, but: https://youtu.be/STFn_B2Sbws

Also remember to use C# Legacy Addin for VS Code.

Ok here is how to get it working:

  1. Install ‘.NET Core SDK for Windows’ from this link: https://www.microsoft.com/net/core
  2. Install MSBuild from https://www.microsoft.com/en-us/download/details.aspx?id=48159 . There should be a folder called ‘c:/Program Files (x86)/MSBuild/version/Bin/’, add this path to your PATH environmental variable if it is not there already.
  3. Edit the .csproj file and set the ‘PlatformTarget’ tag and set the value to ‘x64’, also check if the ‘OutputPath’ tag is also correct. Just do a ‘Search&Replace’ on the the string ‘x86’. (not tested, I changed it in my office copy of Visual Studio 2015)
  4. Open your project’s folder in VSCode. Click on one of the .cs files, it should do some stuff… check your Output window (ctrl+shift+u)
  5. Add the following build task files:
    { // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "0.1.0", "command": "msbuild", "args": [ // Ask msbuild to generate full paths for file names. "/property:GenerateFullPaths=true" ], "taskSelector": "/t:", "showOutput": "silent", "tasks": [ { "taskName": "build", // Show the output window only if unrecognized errors occur. "showOutput": "silent", // Use the standard MS compiler pattern to detect errors, warnings and infos "problemMatcher": "$msCompile" } ] }
  6. Add the following ‘launch.json’ file, you can also press F5 and select ‘.NET Core’.
    { "version": "0.2.0", "configurations": [ { "name": ".NET Core Launch (console)", "type": "coreclr", "request": "launch", "preLaunchTask": "build", "program": "${workspaceRoot}/bin/x64/Debug/<Project_EXE_File>.exe", "args": [], "cwd": "${workspaceRoot}", "stopAtEntry": false, "externalConsole": false }, { "name": ".NET Core Attach", "type": "coreclr", "request": "attach", "processId": "${command.pickProcess}" } ] }

Please note this will probably work for you with a bit of tweaking. If I missed steps please post them so we can get a little complete guide going.

I just realized that I misread a part of your post, sorry about that, my previous reply was pointless…

Anyway I’ll probably do an updated tutorial which also shows how to set it up for Windows in a few days.

Wrote a blog post about MonoGame and Visual Studio Code. (Linux Tutorial and Windows link)

1 Like