Torch Plugin Template
This page describes, how to import the Torch plugin template into your Visual Studio, and creates a step by step guide on how to set up your project with it.
Don't worry, it will be quite simple.
Download the template
The Template is located here:
Import the template to Visual Studio
You find your Visual Studios files located within your Documents folder.
Inside it you find a folder 'Templates' and inside that 'ProjectTemplates'.
All you need to do is to drop the zip file in there as shown below.
Alternatively you can get to it using C:\Users\marti\Documents\Visual Studio 2019\Templates\ProjectTemplates
In case you don't use VS 2019 you of course have to change the version.
Now the template is properly installed and you can start using it. Be careful, you may have to restart Visual Studio before it shows up.
Create your Project
When you create a new project, you can now search for Torch in your templates.
Simply select it and proceed normally like with every project.
It is recommended to use a simple name, preferably without spaces and special characters. (Yes German umlauts are special characters).
In this example we call our project 'Demo'
Once the project is created your project explorer looks like this:
However you are not done yet, since the references are still broken.
Setup project references
To fix the references first you have to close the project and go to its location on your disk.
you will notice this obvious Setup bat file. when you run it, it will ask for the locations of the Space Engineers Dedicated Server and Torch. Don't worry, if you have Torch installed and started up once it comes with everything you need.
Of course the path to your Torch directory will be different, but the DedicatedServer64 folder will still reside inside Torch.
Once executed you see 2 new symbolic links in your project.
You can now open your solution again, and the reference errors should be gone.
It may take a while, till VS updates the references in the project explorer. After opening a class it was ~10 seconds till the compile errors vanished.
Build your plugin
The plugin itself is already pretty much done. Once the compile errors are gone, you can already build it.
You get two outputs:
First you get the plugins dll, pdb and manifest.xml in your 'bin' directory.
And you get a zipped plugin, ready to upload to Torch or to copy in your servers plugin folder in the 'Build' directory.
Read the README
The README file contains some information about what is already set up for you, and what the different files do. Apart from that its setup guide is a bit more simplistic than this one here.
After you have read it you can dispose of it.
The Setup bat you may want to keep, in case you are moving your project to a different folder, or plan to share it through Github. In that case other people may need it to set the project on their own machine.
Don't forget to add the symlinks to your gitignore file later, otherwise Github will not be happy about the size of your project, as it would contain the entirety of Torch.
we added a .gitignore file to the template, hoping to prevent that from happening.
You are now prepared to convert this template into your very own plugin.