How to open an existing .Net Core project Visual Studio Solution in Visual Studio Code (VSCODE)
Posted by John Ademola | August 28, 2019 | ASP.NET, ASP.NET Core 2.2, VisualStudio, VSCode
We are going to see how we can open an existing ASP.NET Core solution project in visual studio code. Firstly, we are going to create an ASP.NET Core web application like below. You can use any Visual Studio Version of your choice but I am going to be using Visual Studio 2019 for this tutorial. Click “create a new project” button like below
Then Search Net Core Web Application, select the option click on the Next button like below.
Click on Create Like Below
Select Web Application and Click Create
Now once you have click the create button, it will create an ASP.NET Core Web Application like below.
Now let’s run that application to make sure that its work fine.
Open ASP.NET Core Solution in Visual Studio Code:
For the Newbies who don’t know What Visual Studio code means, you can find the meaning here https://en.wikipedia.org/wiki/Visual_Studio_Code and you can check out their official web site https://code.visualstudio.com/
Download VSCode : https://code.visualstudio.com/download and follow the installation instructions. It is quite understandable.
After Installation. Open Visual Studio Code by typing it in your search programs. Run it and it would show a screen like below
Click on the Extensions symbol like below and search for C# extensions and .Net Core Extensions
When you install those extensions, OmniSharp would also be installed. OmniSharp is a set of tooling and editor integrations and Libraries that together creates great IntelliSense and other tooling support for popular editors like Code, Sublime Text, Brackets, Atom,Emacs and Vim etc. You can find more information about that on the following link.
Once you click on that text you can also see the progress of installation of Omnisharp libraries in output windows like below.
Since Visual Studio Code is not a full IDE(Integrated Development Environment) like Visual Studio. We need to open the folder which contains the solution and source code. You can do that from Visual Studio Code. Go to the Sub Directory of the Project “Hello World” and Select the folder “Hello World”. Sometimes the name of the folder could be “src” or the Name you gave to the project while setting it up. The name of my project is “HelloWorld”
You would see your files in Visual Studio Code as below.
Now to run this project, We would need to open Terminal>Select New Terminal. and it would open a small window below your Visual Studio Code like below.
You might also see some pop ups at the right bottom corner of your screen asking you to either restore packages of existing projects or Add required assets to build that are missing. Just click “yes”.
Now make sure the command line is pointing to the root of your project just like it is in the screen shot above for mine which is C:\Helloword\Helloworld.
Type “dotnet run — — p”
Copy the localhost url from the terminal and paste in a browser to launch
Now that is how to open an existing project in Visual Studio and run
Disclaimer: I have tested it on the windows machine and its works perfectly fine. For macOS and Linux I would expect the same. For further information, you can follow a GitHub Issue which is already created by the community. You can find that GitHub issue at the following link.
https://github.com/OmniSharp/omnisharp-vscode/issues/283
That’s it. It’s very easy to use light weight Visual Studio Code for same development experience like Full Visual Studio.