Skip to content

Visual Studio Setup

Digi edited this page Nov 17, 2022 · 27 revisions

If you landed here without first seeing Quick Intro to SE Modding then I highly recommend first reading that, there's important information on the scripting section.


First, get the tool from: visualstudio.microsoft.com.

The community edition is free, which requires a (also free) Microsoft account login to continue to work after 30 days, tiny price to pay for the huge amount of help this tool provides.

NOTE: "Visual Studio Code" is a completely different tool, this guide is for Visual Studio, 2019 community edition in particular but it should work for slightly older or newer versions aswell.

Installation

Workloads: .NET desktop development

In Individual Components tab above, have either .NET framework 4.6.1 targetting pack or .NET framework 4.8 targetting pack.

Everything else is up to you.

Creating solution/project

1. Create a new project, Class Library (.NET Framework) for C#, click Next, then pick Framework: .NET Framework 4.6.1 or 4.8 depending on which one you have installed for VS.

NOTE: When creating project make sure you pick .NET framework type, there's also .NET core and .NET standard which are different things.

What folder you pick is up to you, it can go in the mod's root folder just fine as long as you don't publish that particular folder and copy to a clean one instead.

NOTE: VS 2019+ will generate some .cs files with some prohibited types causing it to fail to compile ingame, because of this I recommend not making the project/solution in the Scripts folder, but in the mod's root folder instead.

Once done, click Create.

2. Build > Configuration Manager then click top-right on "Active solution platform" and <New...>, then pick x64 platform and OK.

3. Project > Add Referrence, Browse, navigate to Space Engineers' Bin64 folder and add:

- netstandard.dll
- ProtoBuf.Net.Core.dll
- System.Collections.Immutable.dll
- Sandbox.Common.dll
- Sandbox.Game.dll
- Sandbox.Graphics.dll
- SpaceEngineers.Game.dll
- SpaceEngineers.ObjectBuilders.dll
- VRage.dll
- VRage.Game.dll
- VRage.Input.dll
- VRage.Library.dll
- VRage.Math.dll
- VRage.Render.dll
- VRage.Render11.dll

4. Optional: Open the References in the solution explorers and select all of them (except Analyzers), right click > Properties then click the down arrow for Copy Local and set it to False.

Copy Local in VS

5. Optional: Since SE mods only allow C# 6 features you should set project to use C# 6.

For VS 2017 (and probably older) you can go in project settings, build, advanced (button bottom-right) and pick the version there. Random guide with pictures..

For VS 2019 and newer, it no longer has a setting in the GUI, you can however add to the .csproj file:

<PropertyGroup>
    <LangVersion>6</LangVersion>
</PropertyGroup>

And if there are any other <LangVersion> present, either change them to 6 or just remove them entirely.

A more in-depth MS guide.


And now you can pretty much start programming your mod!

You can also make this project a template so you can speed up future projects creations, in Project -> Export Template.

Next steps

Go back to the quick intro guide to see what to do next in regards to scripting.

Clone this wiki locally