Modding:Setting up your Development Environment: Difference between revisions

From Vintage Story Wiki
VS 2022 add .NET desktop dev, add mod packaging, updated cli commands, VSCode extensions
m (fixed wrong default vs linux install path)
(VS 2022 add .NET desktop dev, add mod packaging, updated cli commands, VSCode extensions)
Line 13: Line 13:


<!--T:4-->
<!--T:4-->
* [https://www.visualstudio.com/en/vs/community/ Visual Studio Community] is a free and very powerful development environment made by Microsoft and has probably the best support for working with C# and dotnet which are also developed by Microsoft. This is also the tool the Vintage Story Team uses to build the game. It also has a [https://www.visualstudio.com/vs/mac/ MacOS Version].
* [https://www.visualstudio.com/en/vs/community/ Visual Studio Community] is a free and very powerful development environment made by Microsoft and has probably the best support for working with C# and dotnet which are also developed by Microsoft. This is also the tool the Vintage Story Team uses to build the game. It also has a [https://www.visualstudio.com/vs/mac/ MacOS Version]. When using it make sure to install the <code>.NET desktop development</code> Workload as well.


<!--T:88-->
<!--T:88-->
Line 131: Line 131:
Open a folder in Visual Studio Code where you want your mod to be. Then open the terminal within Visual Studio code ''Terminal'' > ''New Terminal''.  
Open a folder in Visual Studio Code where you want your mod to be. Then open the terminal within Visual Studio code ''Terminal'' > ''New Terminal''.  


* Create a new Mod Project with launch.json and task.json to easily start it
* Create a new Mod Project with launch.json and task.json to easily start it and a Solution file. ''Other IDE's create that automatically so that is why we have this additional <code>--AddSolutionFile</code> flag for VS Code.''
<syntaxhighlight lang=shell>
<syntaxhighlight lang=shell>
dotnet new vsmod --IncludeVSCode
dotnet new vsmod --IncludeVSCode --AddSolutionFile
</syntaxhighlight>
</syntaxhighlight>


Line 140: Line 140:
dotnet new vsmod --help
dotnet new vsmod --help
</syntaxhighlight>
</syntaxhighlight>
Once you opened or created a template Visual Studio will prompt you to install the recommended extension, click on ''Show Recommendations'' and install the the pre-release version of the [https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit C# Dev Kit] extension. This will also install the required [https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp C#] automatically for you.
These two extensions are recommended and will add Syntax highlighting, Autocomlet and many more much-needed features for writing C# code.


==== Other / Commandline ====
==== Other / Commandline ====
Line 146: Line 149:
* Create a new VS mod in the folder ''mytestmod'' in the current location of the terminal.
* Create a new VS mod in the folder ''mytestmod'' in the current location of the terminal.
<syntaxhighlight lang=shell>
<syntaxhighlight lang=shell>
dotnet new vsmod -o mytestmod
dotnet new vsmod --AddSolutionFile -o mytestmod
</syntaxhighlight>
</syntaxhighlight>


* or create a dll/code only mod
* or create a dll/code only mod
<syntaxhighlight lang=shell>
<syntaxhighlight lang=shell>
dotnet new vsmoddll -o mytestmod
dotnet new vsmoddll --AddSolutionFile -o mytestmod
</syntaxhighlight>
</syntaxhighlight>


Line 163: Line 166:
<syntaxhighlight lang=shell>
<syntaxhighlight lang=shell>
# Will create a new Mod Project with the dependency for VSSurvivalMod
# Will create a new Mod Project with the dependency for VSSurvivalMod
dotnet new vsmod --IncludeVSSurvivalMod -o mytestmod
dotnet new vsmod --AddSolutionFile --IncludeVSSurvivalMod -o mytestmod
</syntaxhighlight>
</syntaxhighlight>


Line 248: Line 251:
<!--T:69-->
<!--T:69-->
If you are having trouble, you might be able to learn from the [https://github.com/anegostudios/vsmodexamples vsmodexamples project]
If you are having trouble, you might be able to learn from the [https://github.com/anegostudios/vsmodexamples vsmodexamples project]
== Packaging the Mod ==
With the new template, we are using the [https://cakebuild.net/ Cake] build system. This includes a second Project within the Solution in the template.
In all supported IDE's you can select from the dropdown that you used to launch the mod the <code>CakeBuild</code> option and run it.
''When using Visual Studio Code you can also create a package by running the package task. For that got to <code>Terminal</code> > <code>Run Task...</code> and select <code>package</code>.''
It will perform a JSON validation on your assets so they are at least parsable by Newtonsoft.Json and then build a <code>Releases/mymodid_1.0.0.zip</code>. The version is taken from the <code>resources/modinfo.json</code> file.
Congratulations now you have your mod development environment set up and a ready-to-release mod package.
Note: Make sure you use your own unique <code>modid</code> else you won't be able to upload the mod to the VSModDB.


= Moving Forward = <!--T:70-->
= Moving Forward = <!--T:70-->
Confirmedusers, editor
18

edits