I periodically have to dip into an ASP.NET Web Forms application and supporting libraries and tests running on the full fat .NET Framework however 99% of my current development work is using the new ASP.NET Core and my current preference is using the CLI tools along with VSCode.

The Web Forms project is just maintenance and support work however I wanted to use the same tooling I have been using day to day without needing to fire up Visual Studio.

Please note there is no actual support for Web Forms with VS Code so debugging, creating new web forms/controls etc is a no-go. For that you will still need to use Visual Studio. This is just my personal setup for general maintenance on an ASP.NET Web Forms project

To do this I have setup a couple of powershell scripts for building, testing and running my applications on IIS Express. I then created a bat file that I dropped into a folder available from my ENV PATH to forward to my powershell script allowing me to alias commands to my scripts.

dotnetframework build myapp
dotnetframework test myapp
dotnetframework run myapp

The powershell script is as follows. I have a few specific conventions and requirements (project folder and csproj names match, projects are all in the root of the solution folder and IIS Express must run as Admin as I have mapped custom hostnames) so you could modify your script to suit your specific solution setup.

param([string]$command, [string]$project)

$solutionPath = Split-Path $MyInvocation.MyCommand.Path
$projectPath = "$solutionPath\$project\$project.csproj"
$testPath = "$solutionPath\$project.Tests\bin\Debug\$project.Tests.dll"

$iisExpress = "C:\Program Files (x86)\IIS Express\iisexpress.exe"
$msBuild = "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe"
$vsTest = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"

if($command -eq "run"){
    Start-Process $issExpress -Verb RunAs -ArgumentList "/config:$solutionPath\.vs\config\applicationhost.config /site:$project"
}
elseif ($command -eq "build") {
    Write-Host "Building: " $projectPath
    & $msBuild $projectPath
}
elseif ($command -eq "test") {
    Write-Host "Running Tests for: " $testPath
    & $vsTest $testPath
}
else {
    Write-Host "Command not found:" $command
}

Create a BAT file in a folder your ENV PATH has access to with the following CLI.ps1 should be renamed to match the script you created above

@echo off
powershell %cd%\CLI.ps1 %*

You can now run the following commands to build, test and run full .NET Framework 4.x applications from the command line and make updates from VS Code.

dotnetframework build myapp
dotnetframework test myapp
dotnetframework run myapp

One caveat is the IIS Express application must be run the first time manually from Visual Studio. This will create the .vs/config/applicationhost.config file with the neccessary IIS Express configured.

You can download and run a sample application showing the above configuration from my GitHub here https://github.com/stevenknox/WebFormsWithVSCodeAndCLI