Now that you have everything to get started, I’m going to create a simple application that we can run. If you have the dotnet core SDK installed, this is fairly simple.
Drop down to your command line / PowerShell and in a new empty folder (I’m using dotnet_sample folder which will become the “name” of the application) simply type :
dotnet new –t web
This will create a bunch of files which is basically a “starter” web application. If you had just typed in “dotnet new” a simple command line “hello world” would have been created.
Even though we have installed dotnet 1.1 core this sample is still being generated to use 1.0.1, so we want to “upgrade” it to use 1.1.
Open up the project.json file and look for the dependencies section:
change the version to 1.1 :
then further down in the file under the “frameworks” section change
The next step is to “install” or download all the dependencies. For this we simply run:
Note: you may have to install gulp (if you are using a clean machine) by typing
npm install -g gulp
A whole bunch of packages are downloaded and installed and gets your application in a state that is ready to run.
Finally, execute the following:
This will “execute” the web application and put it into a run state.
If you navigate (using your favorite browser) to http://localhost:5000 you should see something like this:
For completeness, here is the PowerShell prompt with the commands that are run chronologically. (yours may look a bit different due to package cache etc.)
Now you have a fancy new application, ready to containerize!
To package a dotnet web app we need to run:
dotnet publish -c Release -o output