Gems: A Few Helpful dotnet commands
This post may be short, but if you’re new to .NET Core, it’s valuable.
After installing .NET on RHEL, you want to get up and running as quickly as possible. After all, what good is a framework without anything to show for it? Well, fearless developer, wait no more; here are a few dotnet commands that will take you from a command prompt to a web site, and beyond:
By now, you might know this basic command to create a “Hello world” console application in C#:
Everything you need to grow your career.
With your free Red Hat Developer program membership, unlock our library of cheat sheets and ebooks on next-generation application development.SIGN UP
Of course, it must be followed by
dotnet restore and then
What if you want to create a very basic ASP.NET MVC web site? Check this out:
dotnet new --type web
When you run it, the console will direct you to http://localhost:5000, and there you’ll find the basic ASP.NET MVC application.
Note: If you are running RHEL in a VM, and you are attempting to reach this web address from the host platform (e.g. you’re running RHEL in VirtualBox on a Windows PC), it won’t work. That’s because the “localhost” in this case is, in fact, the VM itself. But the fix is easy; simply modify the one line in the file “Program.cs” to read
.UseStartup<Startup>().UseUrls("http:*:5000"). This will expose the site to the host.
You want to dabble in F#? Check this out:
dotnew new --lang F#
That’s right; the ubiquitous “Hello world” app in F#.
Finally, I’ll leave you with this command to play around with. Create an ASP.NET MVC app (
dotnet new -t web), then try this:
There’s much more to come — enough to fill a book — but for now, this will keep you moving ahead.
All The Best,