Setting Up a Development Environment using Visual Studio

From GTA Network Wiki
Jump to: navigation, search

Setting Up a Development Environment using Visual Studio

Requirements

  • Basic C# programming knowledge

Introduction

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 auto completion. Therefor, following instructions 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.

Before we start, we recommend using Visual Studio 2017 since our API now runs on .NET Core 2.0

Installation process

The installation of both Visual Studio 2017 is fairly simple, the installer by default does not install the required packages, so we're gonna do that on our own. Once we run the installer, we'll be prompted to choose our install options/packages, by default the Visual Studio installs the required files for the standard .NET development but not the new experimental one, so we'll make sure to install the experimental .NET Core development packages by clicking on it.

awe.png

Creating a new project

Once the install has finished, we can proceed by creating our first project.

Start by going to File -> New -> Project -> Visual C# -> .NET Core -> Class Library (.NET Core)

In this tutorial, I'm going to name my resource EpicStunts and place it in the resources folder of the server.

newproj.png



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". name it "meta.xml" and then put your meta.xml content there.

vstudioempty.png

Installing the API package

Now that we've set up our resource, all that we need is the API so that we can get the IntelliSense fanciness.

So what we're gonna do is, right click on "Dependencies" in the Solution Explorer of your project, and click on "Manage NuGet Packages".

ref.png



We should now see a new window, make sure to click on Browse tab. In the search bar, type in "gtanetwork.api" and it should return a package, click on it, then click Install and wait for it to finish installing.

Once it's done, we'll be ready to start scripting.

devenv2.png



Adding another resource to the project

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.

devenv 2017-11-16 00-29-42.png



Then again, Visual C# -> .NET Core -> Class Library (.NET Core), write in the resource name and the resources folder of the server.

Remember, you will still have to manually add and maintain a meta.xml for the resource.

newproj.png



Optionals

Using the following tricks, you can increase your productivity.

Automatic meta.xml generation

To increase speed of development, you may set up the automatic meta.xml generator external application.

It will generate a meta.xml with all the files in the resource folder for you, every time a file changes.