Skip to content

dev.VisualStudioCodeSetup

Thomas Mann edited this page Jan 14, 2024 · 1 revision

VScode environment setup

We'll describe here how to setup the most popular C# related official extensions, in order to build and debug tooll3

Requisites

Pull t3 code

  • In VSCode dashboard, clone this Github repository (Clone Git Repo... > clone from Github > lookup tooll3/t3)
  • choose a destination folder, cloning the repo will take a few seconds/minutes, click "Open" when prompted.
  • (vscode will likely prompt you about trust you have for the authors, your move)
  • Run the install script: Open a shell (Ctrl+backtick), hit cd Install, and then .\install.bat
  • Also build the player: go back to root of the project (cd ..) ...
  • finally run : dotnet.exe build /p:Configuration=Release Player

Using C# Dev Kit

This is the most automated approach, also the least noisy (doesn't use the .vscode folder ;) )

  • Go in the explorer (files sidebar) tabs, unfold "Solution explorer" at the bottom
  • Right click "Editor" and hit "Build" (the project will get built, this takes a bit)
  • Hit Ctrl+Shift+P, and choose "Select and start debugging" > C#... > Editor

Now you can build/run the Editor project just hitting F5

Using C#

This is a more legacy approach, you'll need to create your own tasks/launch JSON files.

Generate tasks.json

(how VScode will trigger builds)

  • hit Ctrl+Shift+P, and choose Tasks: Configure task > dotnet: build
  • try it using Ctrl+Shift+B, you should get a successful MSBuild in your terminal

Generate launch.json

(how vscode run what you build in the debugger)

  • Open the Debug sidebar (Ctrl+Shift+D), click create a launch.json file (under the Run and debug button)
  • Choose .NET5+ and .NET Core in the pop-up menu.
  • This will create and open a .vscode/launch.json file at the root of the repo
  • Click Add configuration..., choose "Launch .NET Core Console App"
  • A new section get added among the configurations array.
  • The program field, need to be set reference the correct DLL file: "${workspaceFolder}/Editor/bin/Debug/net6.0-windows/T3Editor.dll" (net6.0-windows will vary with your setup/version)
  • Add a line referencing the build job (we set in tasks, cf. previous section) :
            "preLaunchTask": "build"

The player Debug task

This step is not mandatory, but it can be useful to run the Player in the debugger too, as an example, here's the configurations as found on my setup:

    "configurations": [
        {
            "name": "Editor (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/Editor/bin/Debug/net6.0-windows/T3Editor.dll",
            "args": [],
            "cwd": "${workspaceFolder}",
            "console": "internalConsole",
            "stopAtEntry": false
        },
        {
            "name": "Player (console)",
            "type": "coreclr",
            "request": "launch",
            "program": "${workspaceFolder}/Export/Player.exe",
            "args": [],
            "cwd": "${workspaceFolder}/Export",
            "console": "internalConsole",
            "stopAtEntry": false
        }
    ]

Conclusion

The second approach will create files in .vscode, if you don't want git to bug you about it, you can add this line to the file .git/info/exclude:

.vscode

Now you should have the build job running with Ctrl+Shift+B, and running the program in the debugger with F5. Congrats, and happy coding.

Clone this wiki locally