How to build project in Visual Studio Code?

Hello there,

So I’m about to start using VSCode for some of my classes and would like to integrate it into my Unity development while I’m using my MacBook. I was able to enable the VSCode plugin and Unity Debugger, but while I’m using standard Visual Studio I’m comfortable to building/compiling the project before going back to the Unity editor to make sure everything compiles correctly. When trying to build a project after opening it in VSCode it displays “No task runner configured.” pop up and after clicking the “Configure Task Runner” button I’m not sure what to do. I’ve tried selecting the MSBuild option, but when I do that there is no build folder selected.

Any help would be much appreciated.

Not sure I’m 100% understanding this, but you should actually be using Unity to do the build for the platform. This will create a project ready to either bring into your IDE (VSCode or Visual Studio), which will then allow you to compile your master/release ready to run.

You may also just use MSBuild at that point to do the compilation.

Yeah sorry I meant to compile the project. I liked to compile the project in Visual Studio before going back to Unity, and I was wondering how to do that with VSCode. Choosing MSBuild on it’s own does not work when I try to compile it.

Same issue here.

In Visual Studio 2015 I could build (compile/link) inside the IDE, without having to switch to Unity, by pressing F6.

How can I do that in VS Code?

I tried configuring the build to MSBuild, but got the output:
"
Failed to launch external program msbuild /property:GenerateFullPaths=true.
spawn msbuild ENOENT
"
Also, I get lots of errors about /unsafe flag for compilation.

Any guidelines for that?

Just to add a little bit, I’ve just installed the Debugger for Unity extension to VS Code.

I had to remove the previous launch.json file that was automatically generated previously.

I could debug normally.

But yet, haven’t found an option to compile/link the code.

2 Likes

You need to configure to build the solution in the tasks.json which VS Code generates automatically. This config should work:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/MySolution.sln"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}

the other option is to run dotnet build MySolution.sln directly in the terminal which is faster, because the fetching of the tasks from the tasks.json takes like 2-3 seconds. Don’t know why it takes so much time.

2 Likes

Not working…