You can develop and run your ASP.NET Core apps cross-platform on Windows, Mac, and Linux. In this module, we'll create a simple app using both the.NET Core command-line interface (CLI) and the. Getting started with ASP.NET 5 and Visual Studio Code on a Mac During Build 2015 Microsoft announced a bunch of new tools aimed at helping developers build cross platform applications. Amongst the announcements, they let us know that ASP.NET was now available and ready to run on Mac and Linux natively.
This post shows you how to get started with an MVC project using Visual Studio Code – the lightweight IDE by Microsoft.
Pre-requisites
- Git – For Version Control (Optional but recommended)
Steps
- Open Visual Studio CodeI am doing this on a brand new Virtual Machine on AWS. The only thing that it has installed on it is Chrome (apart from the Windows Server 2016 defaults ).So, as you can see VS Code is asking me to install Git for version control. It is not required, but I highly recommend that you install and use it for all your projects.Once, I have Git installed, re-opening VS Code looks like this
- VS Code has a Terminal built in. Open it by clicking on the Terminal tab at the bottom. Alternatively you could use the shortcut Ctrl + `
- Create a new directory for your project.
mkdir hello-world-project
- Change to the newly created project directory
cd hello-world-project
- Create a new .NET Core project of type mvc https://ojqzwdl.weebly.com/visual-studio-2012-for-mac.html.
dotnet new mvc
You should get an output like this:-If you get the following error then you don’t have .NET Core SDK installed. Install it from here. Make sure you restart VS Code after installing it because the changes to path settings will only apply on re-launch of VS Code. - Now you can open this project folder using the Open Folder menuAlternatively, you can type
code .
from the terminal which will open up a new Visual Studio Code Window with the project directory. After this, close the previous VS Code window. - Part of the reason why VSCode is so light is that support for various features have been moved into extensions. In order to support C# projects you will need to install the C# extension for VSCode.Opening up any C# code file, will automatically show this suggestion if you do not have the plugin installed.Alternatively, you can go to the Extensions Tab (Ctrl + Shift + X) and search for C# and from there install the one from MicrosoftYou will see it being Installed briefly.Then hit the Reload button to restart VS Code with the extension enabled.VS Code will automatically install C# dependencies such as: OmniSharp & .NET Core Debugger.After this you will get another warning that says that the required assets to build & debug this project are missing.If I don’t install it and hit F5, VS Code asks me to select the environment to start debugging with.So, when you install the missing assets, VS Code creates a .vscode directory with two files – launch.json & tasks.json which allow you to run/debug your project. Microsft visual studio mac os for college student.Now, Hit F5 to start debugging your ASP .NET Core application.In the Terminal you will get an output like this:-In the Debug Console you will see something like this:-In the Threads pane you will see a lot of threads running for your Kestrel web server.And finally, your ASP .NET Core MVC Application will run inside the browser:-
Rating: 5.0/5. From 1 vote.
Related Posts
Using Visual Studio For Mac Asp.net Core Mvc Architecture
- Adding Git to Visual Studio Code ASP .NET MVC ProjectVisual studio for mac tests not running. This post shows you how to start version controlling (via Git) your ASP .NET project…