Previously I posted about what is expected in ASP.NET Core 1.0 RC2 and then posted about what’s new in ASP.NET Core 1.0 RC2. Some of the important changes from RC1 to RC2 are the introduction of new command line tool named “dotnet” to replace “dnx” and moving towards .NET Platform Standards. And I think we are now getting closer to ASP.NET Core 1.0 RC2 release as in last week ASP.NET team released a sample ASP.NET Core 1.0 RC2 project. In this post, I will take you through how to download, build and run this sample project.
First look at ASP.NET Core 1.0 RC2
First install the .NET Core SDK installer. You can download the installer from here and select the proper installer based on your OS. Remember, if you have previously installed dotnet cli then remove it manually. The new setup will not overwrite it for now.
Once downloaded, install the .NET SDK.
And once the installation is finished, you need to restart your system. Let’s first verify that it is installed properly. Go to command prompt and type
And you should see “1.0.0-rc2-002392” as response.
Now, clone the github repo for RC2 sample project from Asp.net cli samples. Either you can clone the repo or you can also download the project as zip. And when you open the cli-samples.sln file in Visual Studio 2015, you will find there are 4 different projects.
But we cannot build and run these sample projects from the studio. Instead, we have to use the dotnet cli tool. So let’s go back to command prompt. Select the directory where “HelloWeb” project is located. And run following command.
This command will restore all the dependencies and nuget packages. It will take few minutes to restore all the packages. And once this is over, let’s build the project.
And it will compile the project against .NETCoreApp 1.0. Now, let’s run the project.
This command will start the application.
And It also start listening on http://localhost:5000. Now open the URL in the browser and you will see “Hello World!”. Cool..
You can skip the
dotnet build step and directly execute
dotnet run command. As dotnet run will also compile the application before starting it. So that’s all about running this project. Remember, you will not be able to create project based on RC2 in Visual studio as the installer is specifically for dotnet command line tool.
Now let’s talk about a couple of new things which are part of the solution. Please note, below listed changes are based on the current ASP.NET Core RC2 sample project and as there is still work in progress so things may change.
Web.config is back
Oh Yes!!! Really surprised to see web.config back in the solution, as ASP.NET Core 1.0 preferred JSON configuration over XML. But at this point of time, it’s not right to make this assumption as well. Because this is still in progress.
There are a couple of new entries in Project.json if we compare with Project.json in RC1.
Inside compilation option, there is an entry
"debugType": "portable", which tells to generate cross-platform PDB files. If the entry is not present then generated PDB files will only be windows based. So if you wish to debug your code on cross-platform, set this to “portable”.
Platform mapping names are changed. So for .NET framework 2 to 4.6, the name would be net20 – net46 and for .NET Core application, it would be netcoreapp. And that’s why you see
netcoreapp present in framework section. And within this, you will also see “imports” section which has value like
portable-net45+wp80+win8+wpa81+dnxcore50. And the description says that it allows packages supporting these frameworks to be installed in this target, regardless of compatibility rules.
The sample project is in early stage of RC2. Since the work for ASP.NET Core RC2 is still in progress and things mentioned above may/may not change when it releases. But we are now hopeful that RC2 will be released soon.
That’s all folks. Keep visiting this blog and share this in your network. Please put your thoughts and feedback in comments section.PS: If you found this content valuable and want to return the favour, then