Porting an existing project to .NET Core 2.0

From GTA Network Wiki
Jump to: navigation, search

Porting an existing project to .NET Core 2.0

Introduction

Porting an existing project from .NET Framework to .NET Core for the API NuGet package compatibility is easy and can be done with the following instructions covered in this page.

Setting up Development Environment

Visual Studio

Before we start, make sure to have installed the .NET Core cross-platform development package from the Visual Studio Installer

awe.png



Visual Studio Code

In order for Visual Studio Code to recognise .NET Core 2.0, it is required to install its SDK which can be done so from here

install.PNG

Porting instructions

0- Make sure to have closed your solution.

1- Navigate to your project folder, you should be able to see your .csproj file.

2- Backup the .csproj. (optionally)

3- Edit the .csproj file using any text editor program.

4- Select everything either with the cursor or by pressing the CTRL+A combination and delete everything.

5- Copy and paste the following lines into the recently emptied window.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
</Project>

6- Save the file and open your solution with your desired IDE.

Installing the API Package:

Visual Studio

1- Navigate to Tools > NuGet Package Manager > Package Manager Console.

2- Copy & Paste the following line into the console: Install-Package gtanetwork.api



Visual Studio Code

In order to open the Terminal (aka Console) in Visual Studio Code, we either use a quick combination that is Ctrl+` or by navigating the menu

1- Navigate to View > Integrated Terminal.

2- Copy & Paste the following line into the console: dotnet add package gtanetwork.api

Adjusting to the updated API

You may have noticed the massive amount of errors popping up in your Error List, which is because the API no longer has methods that start in lowercase letter, instead, they start in an Uppercase letter following the standard naming conventions.

So if you feel lazy doing the changes on your own, worry no more, we've made a little program that does it for you. (you lazy ass!)

Read the Changelog

Thanks to StreetGT's efforts, the program can be found on Github and the instructions are as clear as the skies in the summer.