Skip to content

Instantly share code, notes, and snippets.

@WillSams
Last active April 13, 2020 15:36
Show Gist options
  • Save WillSams/6ffb3a9e0f555933c7d12f87f6409489 to your computer and use it in GitHub Desktop.
Save WillSams/6ffb3a9e0f555933c7d12f87f6409489 to your computer and use it in GitHub Desktop.
Debug Legacy .NET in VS Code on Windows
#!/bin/bash
echo "********************************************************************"
echo
echo " Debug Legacy .NET in VS Code on Windows "
echo " Pre-req: Latest 64-bit MSYS2 from http://www.msys2.org/ "
echo
echo " Howto: Use 'wget' to download the raw version of this script "
echo " and execute the following from the MSys2 command-line: "
echo " chmod +x debug-legacy-dotnet-in-vscode.sh "
echo " ./debug-legacy-dotnet-in-vscode.sh "
echo
echo " Not fully tested, but this *should* work for most Windows users. "
echo
echo "********************************************************************"
echo "Begin!"
mkdir -p $HOME/debug-legacy && cd $HOME/debug-legacy
wget https://aka.ms/vs/16/release/vs_buildtools.exe
./vs_buildtools.exe --add "Microsoft.VisualStudio.Workload.MSBuildTools" --add "Microsoft.VisualStudio.Workload.WebBuildTools"
echo "Select options you want to install or just click 'Install' to install only the web tools."
mkdir -p ~/.nuget && cd ~/.nuget
wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
cd $HOME/debug-legacy
wget https://download.microsoft.com/download/C/E/8/CE8D18F5-D4C0-45B5-B531-ADECD637A1AA/iisexpress_amd64_en-US.msi # get IIS Express 10
./iisexpress_amd64_en-US.msi
# Let's set variables.
nuget_path="'/c/Program Files (x86)/NuGet'"
iisexpress_path="'/c/Program Files (x86)/IIS Express'"
msbuild_tools_path="'/c/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/MSBuild/Current/Bin'"
echo -e "PATH=$PATH:$nuget_path:$iisexpress_path:$msbuild_tools_path" >> ~/.bashrc
source ~/.bashrc
echo "Done!"
# Usage in your solution root:
# dotnet clean
# nuget config -Set repositoryPath=$HOME/.nuget/packages # do this once
# nuget restore
# msbuild.exe -p:configuration=debug
# cmd /c iisexpressadmincmd setupsslurl -url:https://localhost:44308 -useselfsigned # do this once
# bash # the last command put you at Windows prompt, this gets you back to bash
# appcmd delete site "MyLegacySite" # remove in case it already exists
# appcmd add site -name:"MyLegacySite" -bindings:https/*:44308:localhost -physicalPath:"$HOME/Projects/my-legacy-site"
# iisexpress -site:MyLegacySite
@WillSams
Copy link
Author

WillSams commented Apr 13, 2020

Todo: I should "sed" the config file instead of issuing these commands. :)

  1. Instead of using appcmd, issue the 'iisexpress /config:"$USERPROFILE/My Documents/IISExpress/config/applicationhost.config"' command and modify the bindings section of that aforementioned config file.
  2. For bindings section, the details would look something like this:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment