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.
Here, you can verify the version. However, when you run dotnet new it will create the project as shown below.
Now, I will go ahead and do dotnet restore. With this, it will pull all the dependencies from the nuget.
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
As you can see, now there is no project.json file. Let me go ahead and run the same with dotnet run.
However, when I open the same in Visual Studio Code, then it will show the below structure.
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.
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.
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.
Now, when I navigate to http://localhost:5000, it will produce the below result.
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.
7,309 total views, 15 views today