From bde63ca5b62e47ec77277aac69c0b80561e60062 Mon Sep 17 00:00:00 2001 From: martincostello Date: Fri, 31 May 2024 12:29:03 +0100 Subject: [PATCH] Add batch files for testing Add batch files to launch Visual Studio (Code) with the locally installed .NET SDK version for use with daily builds. --- startvs.cmd | 24 ++++++++++++++++++++++++ startvscode.cmd | 29 +++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 startvs.cmd create mode 100644 startvscode.cmd diff --git a/startvs.cmd b/startvs.cmd new file mode 100644 index 00000000..6a073110 --- /dev/null +++ b/startvs.cmd @@ -0,0 +1,24 @@ +@ECHO OFF +SETLOCAL + +:: This command launches a Visual Studio solution with environment variables required to use a local version of the .NET SDK. + +:: This tells .NET to use the same dotnet.exe that the build script uses. +SET DOTNET_ROOT=%~dp0.dotnetcli +SET DOTNET_ROOT(x86)=%~dp0.dotnetcli\x86 + +:: Put our local dotnet.exe on PATH first so Visual Studio knows which one to use. +SET PATH=%DOTNET_ROOT%;%PATH% + +SET sln=%~dp0ProjectEuler.sln + +IF NOT EXIST "%DOTNET_ROOT%\dotnet.exe" ( + echo The .NET SDK has not yet been installed. Run `%~dp0build.ps1` to install it + exit /b 1 +) + +IF "%VSINSTALLDIR%" == "" ( + start "" "%sln%" +) else ( + "%VSINSTALLDIR%\Common7\IDE\devenv.com" "%sln%" +) diff --git a/startvscode.cmd b/startvscode.cmd new file mode 100644 index 00000000..45ea8f6d --- /dev/null +++ b/startvscode.cmd @@ -0,0 +1,29 @@ +@ECHO OFF +SETLOCAL + +:: This command launches Visual Studio Code with environment variables required to use a local version of the .NET SDK. + +:: This tells .NET to use the same dotnet.exe that the build script uses. +SET DOTNET_ROOT=%~dp0.dotnetcli +SET DOTNET_ROOT(x86)=%~dp0.dotnetcli\x86 + +:: Put our local dotnet.exe on PATH first so Visual Studio Code knows which one to use. +SET PATH=%DOTNET_ROOT%;%PATH% + +:: Sets the Target Framework for Visual Studio Code. +SET TARGET=net9.0 + +SET FOLDER=%~1 + +IF NOT EXIST "%DOTNET_ROOT%\dotnet.exe" ( + echo The .NET SDK has not yet been installed. Run `%~dp0build.ps1` to install it + exit /b 1 +) + +IF "%FOLDER%"=="" ( + code . +) else ( + code "%FOLDER%" +) + +exit /b 1