Visual Studio Setup (old) - THDigi/SE-ModScript-Examples GitHub Wiki
This is the previous guide to VS which has the references manually added in, kept for backwards compatibility and knowledge reference on what dlls mods would use.
Highly recommended to follow the up-to-date setup guide instead: https://spaceengineers.wiki.gg/wiki/Modding/Tutorials/Setup_Visual_Studio
Old content
Workloads: .NET desktop development
In Individual Components tab above, have .NET framework 4.8 targeting pack.
Everything else is up to you.
The .NET standard/core one:
You might've noticed we're not making a .NET Framework project, that's because we also want the newer .NET SDK .csproj format which is nicer to use in some ways, but it also makes it way easier to use the MDK2 mod analyzer.
A few things to be aware of:
- VS will create a folder as the project name in the Location.
- Compiling generates some .cs files in the obj folder which will trigger the game's whitelist, preventing your mod from compiling. To avoid this you should not have the project in Data\Scripts\, you can have it in mod's root folder or somewhere else entirely if you want to set up some post-build copying or something.
- You can simply create the project elsewhere then move the contents to your mod or somewhere else too.
Leave Target Framework to what it is, we'll override it later anyway.
At the top it says [Debug] [Any CPU]
, from [Any CPU] drop down you can go to Configuration manager:
Then Active Solution Platform's drop down pick <New...>, it should pre-select x64 and then just click Ok.
Ensure project's platform is also using that newly made x64.
This simplifies a lot of manual configuration with one swoop.
Once project is created and loaded, double-click the project to open the .csproj file for editing.
Note that it will automatically download the latest version of MDK2 mod analyzer through NuGet, if you don't want it you can remove its ItemGroup from the XML.
Then replace its contents with:
(Top-right of the box you can copy all in one click)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>YourName.ModName</RootNamespace>
<TargetFramework>net48</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>6</LangVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Mal.Mdk2.ModAnalyzers" Version="*" />
</ItemGroup>
<ItemGroup>
<Reference Include="ProtoBuf.Net.Core">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\ProtoBuf.Net.Core.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Sandbox.Common">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\Sandbox.Common.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Sandbox.Game">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\Sandbox.Game.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Sandbox.Graphics">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\Sandbox.Graphics.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="SpaceEngineers.Game">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\SpaceEngineers.Game.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="SpaceEngineers.ObjectBuilders">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\SpaceEngineers.ObjectBuilders.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="VRage">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="VRage.Game">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.Game.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="VRage.Input">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.Input.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="VRage.Library">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.Library.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="VRage.Math">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.Math.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="VRage.Render">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.Render.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="System.Collections.Immutable">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\System.Collections.Immutable.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup>
</Project>
Don't save yet, see next step.
Find-and-replace (Ctrl+H) all the paths from <HintPath>
to point to your SE install folder.
Also optionally change <RootNamespace>
as it affects the namespace of newly created classes.
Now save the .csproj file (Ctrl+S).
It might ask by itself or might not, but better safe and just reload the solution: File -> Close solution, then pick the solution again in the window that pops up (or File -> Start window if it doesn't pop up).
If you want to test the whitelist checker, type System.Threading.Thread t;
in a class and see if it complains.
And now you can pretty much start programming your mod! You'll need some template classes to get started so follow the link below.
You can also make this project a template so you can speed up future projects creations, in Project -> Export Template.
Go back to the quick intro guide to see what to do next in regards to scripting.