<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: laxcivo</title>
    <description>The latest articles on DEV Community by laxcivo (@laxedo17).</description>
    <link>https://dev.to/laxedo17</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F245038%2Ff58eb7d6-f734-4b1e-92e4-41868eea3bdb.png</url>
      <title>DEV Community: laxcivo</title>
      <link>https://dev.to/laxedo17</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/laxedo17"/>
    <language>en</language>
    <item>
      <title>How to use Visual Studio Code for almost everything .NET without using full-fledged Visual Studio</title>
      <dc:creator>laxcivo</dc:creator>
      <pubDate>Sat, 25 Apr 2020 19:58:32 +0000</pubDate>
      <link>https://dev.to/laxedo17/how-to-use-visual-studio-code-for-everything-net-without-using-full-fledged-visual-studio-at-all-3klp</link>
      <guid>https://dev.to/laxedo17/how-to-use-visual-studio-code-for-everything-net-without-using-full-fledged-visual-studio-at-all-3klp</guid>
      <description>&lt;p&gt;For those like me who study and work in .NET projects and would like to use Visual Studio Code for almost everything instead of Visual Studio..., you can in some projects -WPF Forms, Xamarin and the like need Visual Studio-. &lt;/p&gt;

&lt;p&gt;This works with xUnit projects, MVC, ASP.NET projects, etc etc.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;WRITING FULL .NET PROJECTS USING VISUAL STUDIO CODE&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;Let's get started writing code with VSC! &lt;/p&gt;

&lt;p&gt;Let's say you want to create a new project. &lt;/p&gt;

&lt;p&gt;In this example I will utilize various mini folders -without touching Visual Studio- in VSCode, which will keep several projects.&lt;/p&gt;

&lt;p&gt;You need the C# (Omnisharp) extension for this, of course.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;** Start Visual Studio Code.** We begin with the very basics.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Navigate to File | Open Folder...,  or press Ctrl + O.&lt;/strong&gt; You can click the Open Folder button in the EXPLORER pane or click the Open Folder... link on the Welcome page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the dialog box, &lt;strong&gt;navigate to your user folder, your Documents folder, or any directory or drive in which you want to save your projects.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the &lt;strong&gt;New Folder&lt;/strong&gt; button and name the folder however you prefer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In that folder, &lt;strong&gt;create a new folder&lt;/strong&gt; with another name you like. In this example I am naming it &lt;em&gt;VSCode&lt;/em&gt;. Here we are going to have all our code and projects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;In the VSCode folder, create a new folder with whatever name you like.&lt;/strong&gt; Say &lt;strong&gt;Project01&lt;/strong&gt; for instance.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;We could follow the same steps to create a Project02 folder, this is VERY important when we want to combine them -more on that in the **Using Visual Studio Code workspaces&lt;/em&gt;* below-.*&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the Project01 folder, create a new folder named HelloCSharp.
Select the HelloCSharp folder and on Windows click Select Folder (on macOS I think it's click Open).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here we are going to create a new console project, as an example.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Navigate to View | Terminal&lt;/strong&gt;. Make sure your terminal is in the HelloCSharp folder, if not navigate to it using the Terminal -like DOS commands-.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In TERMINAL, enter the following command:&lt;br&gt;
&lt;strong&gt;dotnet new console&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;NOTE: Full list of dotnet cli commands here&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-new"&gt;https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-new&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You will see that &lt;strong&gt;the dotnet command-line tool creates a new Console&lt;br&gt;
Application project for you in the current folder&lt;/strong&gt;, and the EXPLORER&lt;br&gt;
window shows the two files created, HelloCSharp.proj and Program.cs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;If you see a warning saying that required assets are missing, click Yes, -this is essential to have VSC running as a VS Code formatter as&lt;br&gt;
shown in the following screenshot:&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7VRI93hb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/tatzdaR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7VRI93hb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/tatzdaR.png" alt="VSCode essential intellisense"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After a few seconds, a folder named .vscode will appear in the EXPLORER&lt;br&gt;
pane. This is used during debugging.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Navigate to File | Auto Save.&lt;/strong&gt; This toggle will save the annoyance of&lt;br&gt;
remembering to save before rebuilding your application each time.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;COMPILING AND RUNNING CODE USING DOTNET CLI&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Navigate to View | Terminal&lt;/strong&gt; and enter the following command in the folder where the program you want to run is:&lt;br&gt;
&lt;strong&gt;dotnet run&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The output in the TERMINAL window will show the result of running your&lt;br&gt;
application.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;USING VISUAL STUDIO CODE WORKSPACES&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;Before we want to create any more projects, let's talk about &lt;strong&gt;workspaces&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Although we could continue to create and open separate folders for each project, it can be useful to have multiple folders open at the same time. &lt;strong&gt;Visual Studio Code has a feature called workspaces that enables this.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's say we started another project called Maths in the Project01 folder along with the HelloCSharp project we already had, and want to create a workspace for two projects we created below it so far.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In Visual Studio Code, &lt;strong&gt;navigate to File | Save Workspace As....&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter Project01 for the workspace name, change to the Project01 folder -if you are not there-, and &lt;strong&gt;click Save&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Navigate to File | Add Folder to Workspace...&lt;/strong&gt;&lt;br&gt;
Select the Maths folder, click &lt;strong&gt;Add&lt;/strong&gt;, and note that both HelloCSharp and Maths&lt;br&gt;
are now part of the Project01 workspace.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In order &lt;strong&gt;to switch between our projects in the workspace&lt;/strong&gt;, press F1 and select &lt;strong&gt;Omnisharp: Select Project.&lt;/strong&gt; You can switch between the HelloCSharp and Maths projects with this. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you don't do that, C# won't use intellisense and other features if you edit files in a project you didn't select, of course. &lt;/p&gt;

&lt;h3&gt;
  
  
  Good Practice: When using workspaces, be careful when entering commands in Terminal. Be sure that you are in the correct folder before entering potentially destructive commands!
&lt;/h3&gt;

&lt;p&gt;So to sum it up. As another example...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In the Project01 folder create a new folder named Love and add it to the Project01 workspace.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Navigate to Terminal | New Terminal.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Go to the Love folder.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enter the command to create a new console application: &lt;strong&gt;dotnet new
console.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Navigate to &lt;strong&gt;View | Command Palette. Enter and select OmniSharp: Select Project.&lt;/strong&gt; (F1 key)&lt;/p&gt;

&lt;p&gt;Select the Love project, and if prompted, click &lt;strong&gt;Yes&lt;/strong&gt; to add required assets to debug.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In Terminal, if you are in the Love project execute the code by entering &lt;strong&gt;dotnet run&lt;/strong&gt;. Rinse and repeat. It's always like that.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;HOW REFERENCES TO OTHER PROJECTS OR DEPENDENCIES WORK&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;Say you created a library project in the Maths folder, with the corresponding command. And you want to reference it from other projects. &lt;/p&gt;

&lt;p&gt;In that case you have to edit the Love.csproj manually and reference the Maths project with something along the lines of -if it is at the same level in the folders structure-:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tiWLX67S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/3bVbhzg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tiWLX67S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/3bVbhzg.png" alt="VSCode csproj example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ItemGroup can reference libraries and Nuget Packages and so on.&lt;/p&gt;

&lt;p&gt;This is a complete example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PYb2EZHL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/zFnRKVQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PYb2EZHL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/zFnRKVQ.png" alt="VSCode complete csproj example with Nuget packages and library references"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you find this complicated, you can create a solution with Visual Studio 2019 and add the references and stuff, and then open the root folder of the project with Visual Studio Code. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you see a warning saying that required assets are missing to click Yes, then everything is fine&lt;/strong&gt; because it means that VSC has detected a VS project and wants to add Intellisense and so on.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you don't, open the Visual Studio 2019 solution with VSC in the previous folder in the folder hierarchy where the .sln file is. This should solve it.&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;CONCLUSION&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;It's basically always the same:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Choose a folder for your code.&lt;/li&gt;
&lt;li&gt;Create a subfolder within, i.e. &lt;strong&gt;Project01&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Save the folder to your workspace with the &lt;strong&gt;Save as Workspace&lt;/strong&gt; option.&lt;/li&gt;
&lt;li&gt;Create another subfolder within Project01, for &lt;strong&gt;a library, console app&lt;/strong&gt;, etc. i.e. MathsLibrary&lt;/li&gt;
&lt;li&gt;Add the new MathsLibrary folder to the Project01 workspace.&lt;/li&gt;
&lt;li&gt;Navigate to &lt;strong&gt;Terminal | New Terminal&lt;/strong&gt;. And go to the MathsLibrary subfolder.&lt;/li&gt;
&lt;li&gt;Enter the command to create a new library application: &lt;strong&gt;dotnet new
classlib&lt;/strong&gt; .&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to &lt;strong&gt;View | Command Palette&lt;/strong&gt;. (or press F1)&lt;br&gt;
Enter and select &lt;strong&gt;OmniSharp: Select Project&lt;/strong&gt;.&lt;br&gt;
Select the MathsLibrary project, and &lt;strong&gt;if prompted, click Yes to add required assets to debug&lt;/strong&gt; -essential.&lt;br&gt;
&lt;strong&gt;Note&lt;/strong&gt;: for a library, once you have the code, type &lt;strong&gt;dotnet build&lt;/strong&gt; so you can reference it on other projects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new subfolder within Project01 named Calculator for instance and add it to the Project01 workspace.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Say this is a console app, go to &lt;strong&gt;Terminal | New Terminal&lt;/strong&gt; and to the Calculator subfolder, type &lt;strong&gt;dotnet new console&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Press F1 and with &lt;strong&gt;Omnisharp: Select Project&lt;/strong&gt;, select the Calculator project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Click Yes to use the required assets when prompted.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In case you want &lt;strong&gt;to reference the MathsLibrary project, you need to edit the .csproj file&lt;/strong&gt; as explained above.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Other helpful stuff
&lt;/h4&gt;

&lt;p&gt;In addition, you can create your own solutions in VS Code with the &lt;strong&gt;Solution Explorer&lt;/strong&gt; extension. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=fernandoescolar.vscode-solution-explorer"&gt;https://marketplace.visualstudio.com/items?itemName=fernandoescolar.vscode-solution-explorer&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I haven't fiddled with it that much yet, but you can create typical Visual Studio solutions that way.&lt;/p&gt;

&lt;p&gt;In order to open existing Visual Studio 2019 -or previous versions- solutions in VSCode, there is a quick and easy to read guide here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@ademolajhon/how-to-open-an-existing-net-core-project-visual-studio-solution-in-visual-studio-code-vscode-a7307380b5f8"&gt;https://medium.com/@ademolajhon/how-to-open-an-existing-net-core-project-visual-studio-solution-in-visual-studio-code-vscode-a7307380b5f8&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Gotta thanks &lt;strong&gt;Mark J. Price&lt;/strong&gt; because thanks to his teachings I learnt to do this by reading his excellent books.&lt;/p&gt;

</description>
      <category>visualstudiocode</category>
      <category>likeanide</category>
      <category>fullfledged</category>
      <category>everythingonvsc</category>
    </item>
  </channel>
</rss>
