.NET Core – Migrations


.NET Core – Migrations


”;


In this chapter, we will migrate the console application which contains the project.json file build system instead of MSBuild (*.csproj). So, we have an old project which contains the following files.

Following Files

Now the question is, why do we need migration? This project is created using .NET Core 1.0 preview 2 tooling and now we have installed .NET Core 2.0 preview 1 tooling. Now when you build this application using .NET Core 2.0 command line utility, then you will see the following error.

Following Error

This is because the project.json build system is no longer available in .NET Core 2.0, so we need migration so that it can work properly. To see the available commands, let us run the following command.

dotnet help 

In the commands section, you can see the different commands and you can also see the migrate command which will migrate a project.json based project to a MSBuild based project.

Migrate

Let us now run the following command.

dotnet migrate 

You will see a summary of the migration process and here you can also see that a project is migrated successfully.

Migrate Sucessfull

Let us now see the directory structure by using the following command.

tree /f 

You will now see the *.csproj file along with Program.cs file in the project root directory and project.json is moved to the backup folder.

Backup Folder

Let us open the console.csproj file. Now you can restore and build this project using the MSBuild system by running the following command.

dotnet restore 

You can now see that all the packages are restored.

Dotnet Restore

You can now build your project with the following command.

dotnet build 

You can now see that the project is built successfully using MSBuild and console.dll is also generated in ..binDebugnetcoreapp1.0 folder.

MSBuild

The following screenshot shows the directory structure and files.

screenshot

Advertisements

”;

Leave a Reply

Your email address will not be published. Required fields are marked *