S&box Wiki

Setting up Visual Studio Code

Setting up Visual Studio Code

Additional configuration is required for Visual Studio Code to work fully, make sure you read the entire article.

Installation and setup

Download and install Visual Studio Code from here.

Install C# extension

You will require the C# Extension in order to work properly with C# in VSCode, simply download this and make sure to reload VSCode.

Enabling Roslyn analyzers

It is incredibly important to enable Roslyn analyzers, you will get errors on generated code if you do not enable them. The simplest way is File -> Preferences -> Settings, from there search for "roslyn" and tick the setting "Enable Roslyn Analyzers".

image.png

Be sure to save your settings.

Opening projects

After creating your addon folder structure and running your game to generate the .csproj files you can open your addon folder in VSCode via File -> Open Folder....

image.png

Adding debugger configuration

We need to add a debugging configuration to debug addons. Create the following file in your addon directory .vscode\launch.json:

{ "version": "0.2.0", "configurations": [ { "name": ".NET Core Attach", "type": "coreclr", "request": "attach", "processName": "sbox.exe", "requireExactSource": false // makes sure you can debug stuff with codegen (e.g entities) } ] }

You can now start debugging your addons by setting breakpoints and pressing F5:

Keep in mind that you need to manually start s&box first before debugging.

Recommended extensions

Visual Studio Keymap: Adds Visual Studio keymaps in case you are used to Visual Studio shortcuts.

JetBrains Keymap: Adds JetBrains keymaps in case you are used to JetBrains shortcuts.

EditorConfig for VS Code: Automatically format your code with the s&box coding style

SCSS Formatter: Automatically format your scss files.

vscode-solution-explorer: Visual Studio-like solution explorer for Visual Studio Code.

C# Snippets: C# code snippets.

Auto-Using for C#: Auto import namespaces.

C# Extensions: Quickly create new classes and generate constructors.

C# Namespace Autocompletion: IntelliSense for writing namespaces.

C# XML Documentation Comments: Easier code documentation.

GitLens: A useful extension when working with Git.

Themes

Visual Studio Code has first-class support for themes. You can browse and install themes from here.

Special Pages


Wikis

?

Render Time: 51ms

DB GetPage 41
Generate Html 0
SaveChanges (1) 7
Render Body 0
Render Sidebar 1