Goodbye project.json, .xproj. Welcome .csproj

Hi Friends,

In this section, I thought to share new changes happened around .Net Core. With the release of ” Version:  1.0.0-preview3-004056“, Microsoft has scrapped the idea of project.json file and .xproj. You can download the updated version from the same link http://dot.net/. Let me quickly show demo around the same.

1st

Here, you can verify the version. However, when you run dotnet new it will create the project as shown below.

2nd

Now, I will go ahead and do dotnet restore. With this, it will pull all the dependencies from the nuget.

3rd

As you can see here in the above screenshot, it created file myblogcore.csproj file. Now, let’s see the files inside the folder. Here, when I type start . , it will open the project in file explorer

4th

As you can see, now there is no project.json file. Let me go ahead and run the same with dotnet run.

5th

However, when I open the same in Visual Studio Code, then it will show the below structure.

6th

Therefore this is one of the major changes with this build. Now, we won’t have project.json file and .xproj type.

However, here the question comes, how about the existing asp.net core projects which is having both type .xproj type and project.json file, will this build with this new change?

Answer is it won’t build, it will give below error.

MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.

Here, the problem here is MSBUILD, unable to find compatible .csproj file. Now, in order to run the same side by side with project.json file, I have included Rehearse.csproj.

I have just copied the .csproj file from the skeleton project which I have created above in the existing project and just renamed the same Rehearse.csproj.

8th

With this change in place, when I go ahead and run the app, then it will pull all the dependencies from project.json file and copied the same into newly created .csproj file and produced the below output.

 9th

Another way, which I find is the coolest is using dotnet migrate command. This will scan all the dependencies listed in project.json file and create one .csproj file and pull all the dependencies there. You can find more about dotnet-migrate at below link.

https://docs.microsoft.com/en-us/dotnet/articles/core/preview3/tools/dotnet-migrate

Now, when I navigate to http://localhost:5000, it will produce the below result.

10th

Although, I loved  project.json very much but it is understandable to some extent like “This will help migrating existing Visual Studio solutions to .NET Core straightforward“. For more details you can refer the below standup as well.

Thanks for joining me. Hope you have enjoyed the article.

Thanks,
Rahul Sahay
Happy Coding

7,309 total views, 15 views today

2 thoughts on “Goodbye project.json, .xproj. Welcome .csproj

  1. Hey,

    It’s not about “This will help migrating existing Visual Studio solutions to .NET Core straightforward” … Rather …. It is about – Should Microsoft change all other technology to use Project.json or change .net core to MSBuild.

    Problem was – when they started out with .net core they found that .json is one of the ways many open source projects go about. So they adapted that. But soon realized that if project.json needs to be adapted for asp.net webform, mvc,wpf,winform etc etc … It’s a mammoth task to change MSBuild.

    Where as changing .net core to adapt to .csproj and msbuild is easier in effort. Hence the change.

    Hope this helps.

    • Yeah, that’s true. But, migration is also one of things which they have been considering. And with this approach, it would be easy. Yes they are making changes in Dot.Net Core but they are also making change in ms-build too, to accommodate the changes. Therefore, this change they are doing both ways so that with minimum effort they can achieve the same. Thanks!
      Rahul recently posted…Goodbye project.json, .xproj. Welcome .csprojMy Profile

Comments are closed.