Setting Up a Development Environment on Windows

From GT-MP
Jump to: navigation, search

Setting up a development environment with Visual Studio

VisualStudio.png

If you're going to be developing in C# a lot, it's preferable if you set up a solution with projects. This gives a lot of benefits, the most important one of those is autocompletion.

This page will explain how to set it up in a way that you don't have to compile your projects to dll's, and still work swiftly and productively.

Visual Studio

Which version of Visual Studio will you be using? You can use any, but since GT-MP runs on .Net 4.5.2, you should at least be using 2010. You can download Visual Studio for free here.

Creating the solution

Let's start by creating our solution. The theory behind this method of setting up Visual Studio is that the "resources" folder is essentially our Visual Studio solution folder.

Start by going to File -> New -> Project, and find "Blank Solution" in the project types. In Visual Studio 2015 (and above), this is likely under Templates -> Other Project Types -> Visual Studio Solutions.

Set the name of the solution to just "resources", and the location to where you have your GT-MP server installed.

NewVS1.png

Once you click OK, a new "resources.sln" is created in your resources folder and the empty solution will be opened in Visual Studio.

Creating a new resource

When you decide to create a new resource, all you have to do in Visual Studio is right click on the solution in the solution explorer, then Add -> New Project. You will then have to find the "Class Library (.NET Framework)" project template and enter a name. The project name you enter in this dialog will be your resource name, so if you wanted to make a cool gamemode called "Epic Stunts" you will probably want to enter "epicstunts" or "epic-stunts" here.

When you click OK, your project will be created and the folder for your resource is also created. You will still have to manually add and maintain a meta.xml for the resource. You can do this either outside of Visual Studio, or inside of Visual Studio by right clicking the project, Add -> New Item, and find "XML File". Give it the name "meta.xml" and then put your meta.xml content there.

Don't forget that when you add files to your project via Visual Studio, you have to manually add them to the meta.xml file.

To get autocompletion to work, you will have to add the GT-MP API to each resource or project that you create. To do this, right click "References" in the solution explorer for your project, and click "Manage NuGet Packages". In the search bar, search for "GT-MP". It should give you a result from the Grand Theft Multiplayer Dev Team. Click on the item, and click Install on the right side, and you're done!

NugetNew1.png

Setting up an existing resource

If you already have a resource that you would like to add to Visual Studio, the process is very similar as above, except when you try to create a project when a folder already exists, you will get this error:

VisualStudio3.png

To work around this, I suggest you temporarily rename your existing folder (for example from "testing" to "testing-temp"), then create the project by the process explained above, and then manually move your files from the temp folder to the new folder. You can then simply drag your files that you moved to the folder into your project.

And that's it! You are now ready to start developing resources with Visual Studio.