How to pass arguments to program, when debugging in Visual Studio Code

Found my answer at: https://github.com/Microsoft/vscode/issues/2167

You have to pass the arguments as individual string elements:

“args”: [


“–test”, “buildOutput/JavaScript1.js”,


“–env”, “devtest-chrome-win8”

]

My program needed a parameter -d and a parameter -s, so I changed the args to:

“args”: [


“-d”, “some value for d”,


“-s”, “some value for s”

]

And those parameters where picked up by the McMaster.Extensions.CommandLineUtils, that I used in the program.

Visual Studio Code – Multiple MSBuild project files found in ‘…’. Specify which to use with the –project option.

When developing, I like to have my tests in the same folder as the code and make the build process excluded test code for a production build (<Compile Remove=”**\*Test.cs” />).
So I created a .NET Core command line application in Visual Studio Code (my.command.line.csproj) and placed a test project file inside the samen folder (my.command.line.test.csproj).

my.command.line.csproj



<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>

<OutputType>Exe</OutputType>

<TargetFramework>netcoreapp2.2</TargetFramework>

</PropertyGroup>

<ItemGroup>

 <Compile Remove="**\*Test.cs" />


</ItemGroup>

</Project>

my.command.line.test.csproj


<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>

<TargetFramework>netcoreapp2.2</TargetFramework>

<IsPackable>false</IsPackable>

<GenerateProgramFile>false</GenerateProgramFile>

</PropertyGroup>

<ItemGroup>

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />

<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />

<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />

</ItemGroup>

</Project>

Then I executed dotnet test

This will throw the following error:
Program.cs(10,27): error CS0017: Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point.

This can be fixed by adding: <GenerateProgramFile>false</GenerateProgramFile> to a PropertyGroup inside the my.command.line.test.csproj.

Then when you execute dotnet test again, you will get the error:

MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.

To fix it, execute:
dotnet test “my.command.line.test.csproj”

When you execute dotnet watch test, you will first get the error

Multiple MSBuild project files found in ‘C:\Dev\’. Specify which to use with the –project option.

You might want to fix it like: dotnet watch –project “my.command.line.test.csproj” test, but then the watcher will start watching but you will get the error:

MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.

watch : Exited with error code 1

watch : Waiting for a file to change before restarting dotnet…

To fix this, execute dotnet watch –project “my.command.line.test.csproj” test “my.command.line.test.csproj”

Now your tests will be executed and the tests will be re-executed, when any of the files change.

Fix Code Spell Checker extension NOT working in Visual Studio Code

I installed the code spell checker extension for Visual Studio Code https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker.

But the spell checker was not working, the status bar showed an exclamation mark icon.

For some reason the spell checker was disabled in the workspace settings:

After this setting was set to true and the workspace settings json file was saved, the code spell checker started working again.

How to create an IIS application pool and web site on Windows 10 with PowerShell and Visual Studio Code

Tasks to create an IIS application pool and web site on Windows 10 with PowerShell and Visual Studio Code:

  • Install the Visual Studio Code plugin PowerShell 0.6.2
  • Create a file iis.configuration.ps1 in Visual Studio Code:

    # Note: When run with the Visual Studio Code PowerShell debugger, make sure you use the "x64" debugger,
    #       else you will get an error: New-WebAppPool : Cannot retrieve the dynamic parameters for the cmdlet.

    Import-Module WebAdministration

    # Create application pools
    New-WebAppPool -Name "myapp.localhost" -Force

    # Create websites
    New-Website -Name "myapp.localhost" -Port 80 -HostHeader "myapp.localhost" -ApplicationPool "myapp.localhost" -PhysicalPath "c:\projects\myapp\web" -Force

        • Create a launch.json in the same folder as the iis.configuration.ps1:

          {
              "version": "0.2.0",
               "configurations": [
                  {
                      "name": "PowerShell",
                      "type": "PowerShell",
                      "request": "launch",
                      "program": "${workspaceRoot}/iis.configuration.ps1",
                      "args": [],
                      "cwd": "${workspaceRoot}/iis.configuration.ps1"
                  },
                   {
                      "name": "PowerShell x86",
                      "type": "PowerShell x86",
                      "request": "launch",
                      "program": "${workspaceRoot}/iis.configuration.ps1",
                      "args": [],
                      "cwd": "${workspaceRoot}/iis.configuration.ps1"
                  }
              ]
          }

          Now you can debug / run the iis.configuration.ps1 file, by hitting F5, make sure you selected “PowerShell” and not “PowerShell x86” on the debug tab:

          image

          Yes, Yes–Integrated Terminal in Visual Studio Code

           

          The killer feature I was missing in Visual Studio Code was a integrated terminal.

           

          More and more I use the command line for all kinds of tasks, but I don’t want to leave my editor, so I’m very glad that the visual studio code team decided to create a integrated terminal, currently it can only by found in the insiders builds, but a stable release containing the integrated terminal is on it’ s way.

           

          To open the integrated terminal hit CTRL + `.

           

          Event the shortcut is convenient Smile.

           

          So to install all the npm packages in your project just hit CTRL + ` and enter npm install:

           

          image