Angular in Visual Studio

October 8, 2020angularvs

Now that the Angular Language Service is available for Visual Studio working on Angular projects from inside Visual Studio is a viable option. The linked blog post mentions a couple of ways of adding the Angular project to Visual Studio but I felt the suggestions left something to be desired here is what I came up with.

Here is the csproj file I came up with:

  <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk.Web" />

    <!-- Don't show node_modules and dist folder -->

    <!-- Properties folder really only exists to make VisualStudio happy. -->
    <Content Remove="Properties/*" />
  <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk.Web" />

  <Target Name="Restore">
    <Exec Command="npm i" />
  <Target Name="Build">
    <Exec Command="npm run build" />

And here is what I ended up with in my launchSettings.json file:

  "profiles": {
    "ng serve": {
      "commandName": "Executable",
      "workingDirectory": "$(ProjectDir)",
      "executablePath": "node_modules\\.bin\\ng.cmd",
      "commandLineArgs": "serve"