Visual Studio Code - Guide
This guide will help you get VS Code Setup as best as possible for 2sxc development.
Tip
You'll often write code in your 2sxc Apps - either as C#/Razor or JavaScript. 2sxc is a very open system, so you can use any editor you like. For quick fixes and simple things, use the built-in editor, which is based on Monaco (VS Code Online). But for more sophisticated stuff we highly recommend VS Code.
Prepare VS Code for 2sxc
VSCode is amazing right out of the box, but to really be productive, you need to do a few things:
- Install VS Code
- Install the C# DevKit extensions
- Configure each App with
- Intellisense (see below)
- Ignore the
objand.vsfolders (see below)
- Check possible edge cases (see below)
With these preparations, VS-Code is able to assist in basic C# code. It can't provide IntelliSense for 2sxc specific APIs yet, so for that, read on.
Setup IntelliSense
- Install DotNet-Project first install the App Extension
- How to Install App Extensions instructions for your first time
Then
- copy the files
app.slnandapp.csprojfrom thetemplatesfolder to your main app folder (or a specific edition-subfolder) - restart VS Code
- if VS Code / C# Dev Kit asks which solution to load, choose the correct
app.slnfor the folder you want to work on
Note
2sxc app setups contains multiple .sln files, so VS Code / C# Dev Kit should usually prompt you to choose one and remember that choice for the workspace.
If it does not load the correct solution reliably, use the .NET: Open Solution command and manually open the root app.sln.
That's it - you should now have IntelliSense on all your C# and Razor files.
➡️ See full instructions here: DotNet Project (VS Code Helper)
GitIgnore Temporary Folders
Add these lines to your .gitignore file to prevent temporary files from being added to your repository:
.vs/
obj/
bin/
Warnings when Using IntelliSense
Warning
IntelliSense can show you internal APIs which will change over time.
IntelliSense is an amazing productivity boost, but you should avoid using internal APIs.
To make this unlikely, we spent a LOT of time to clearly mark internal stuff. Avoid the following:
- Almost everything in the
ToSic.Eav.*namespace is usually internal, so avoid using it- Exception: ToSic.Eav.Data, ToSic.Eav.DataSource and ToSic.Eav.DataSources are really public
- Anything in a
*.Internalnamespace - Anything in a
*.Integrationnamespace - Anything in a
*.Backendnamespace - Anything in a
*.Sysnamespace - Anything marked with
[Obsolete] - Anything marked with
[EditorBrowsable(EditorBrowsableState.Never)]- IntelliSense will not show these APIs - Properties beginning with an underscore, eg
_Something
Known Issues when C# IntelliSense is not Working
Here we try to collect known issues and solutions.
- A razor file has the same name as a C# class in the AppCode Folder
This will confuse the IntelliSense, since the Razor file will magically be seen as a class with the same name. Solution: Rename the Razor file to something else.
Configure an App for JavaScript IntelliSense
TODO: this is not yet documented
Other Guides
History
- Added v16.07 2023-10
- 2024-06-19 - Added more details about the
.csprojfile incl. date-version and correct DNN System.Net.Http reference - 2026-03-21 major update with complex
.csprojwhich is outsourced to the DotNet Project extension.
Shortlink: https://go.2sxc.org/vscode