From 7f0cad5efad9e6e8752edeb8060242f82c81cbc2 Mon Sep 17 00:00:00 2001 From: geo Date: Sun, 24 Mar 2024 11:13:31 +0100 Subject: [PATCH 1/2] Added a Paths.cmd template so users can add their local VisualStudio version easily. The old one was locked to 2019 enterprise. --- .gitignore | 1 + Build.cmd | 9 ++++++++- Paths.cmd.template | 12 ++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 Paths.cmd.template diff --git a/.gitignore b/.gitignore index 3e759b7..a1b9553 100644 --- a/.gitignore +++ b/.gitignore @@ -328,3 +328,4 @@ ASALocalRun/ # MFractors (Xamarin productivity tool) working folder .mfractor/ +/Paths.cmd diff --git a/Build.cmd b/Build.cmd index 88aae09..7191a7d 100644 --- a/Build.cmd +++ b/Build.cmd @@ -4,7 +4,14 @@ if exist Debug rd /s /q Debug if exist Release rd /s /q Release if exist x64 rd /s /q x64 -"%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" /p:Configuration=Release +IF NOT EXIST "Paths.cmd" ( +ECHO Please copy "Paths.cmd.template", enter your Visual Studio path and rename it to "Paths.cmd". +PAUSE +GOTO exit +) + +call Paths.cmd +"%VISUAL_STUDIO_PATH%" /p:Configuration=Release :exit popd diff --git a/Paths.cmd.template b/Paths.cmd.template new file mode 100644 index 0000000..d05068b --- /dev/null +++ b/Paths.cmd.template @@ -0,0 +1,12 @@ +@echo off +:: Set your Visual Studio path here. +:: TODO: Make visual studio path auto detection. + +:: Enterprise path +SET VISUAL_STUDIO_PATH=%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe + +:: Community path +::SET VISUAL_STUDIO_PATH=%programfiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe + +echo Using Visual Studio path:%VISUAL_STUDIO_PATH% +@echo on \ No newline at end of file From 417e98aab0a84697660141cc0a73b1a758afb422 Mon Sep 17 00:00:00 2001 From: geo Date: Wed, 3 Apr 2024 15:13:53 +0200 Subject: [PATCH 2/2] Adds auto detection for visual studio 2019 and 2022. --- Build.cmd | 55 ++++++++++++++++++++++++++++++++++++++++------ Paths.cmd.template | 12 ++-------- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/Build.cmd b/Build.cmd index 7191a7d..96f1597 100644 --- a/Build.cmd +++ b/Build.cmd @@ -1,18 +1,59 @@ @echo off + +REM Default VS paths to check if no Paths.cmd file exists +set VISUAL_STUDIO_PATH_0="%programfiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe" +set VISUAL_STUDIO_PATH_1="%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" +set VISUAL_STUDIO_PATH_2="%programfiles(x86)%\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\msbuild.exe" +set VISUAL_STUDIO_PATH_3="%programfiles(x86)%\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\msbuild.exe" + pushd "%~dp0" if exist Debug rd /s /q Debug if exist Release rd /s /q Release if exist x64 rd /s /q x64 -IF NOT EXIST "Paths.cmd" ( -ECHO Please copy "Paths.cmd.template", enter your Visual Studio path and rename it to "Paths.cmd". -PAUSE -GOTO exit +if exist "Paths.cmd" ( +REM Prefer Paths.cmd as Visual Studio path source if it exists. +call Paths.cmd +goto build +) else ( +REM Otherwise try to auto-detect the Visual Studio path. +if exist %VISUAL_STUDIO_PATH_0% ( +set VISUAL_STUDIO_PATH=%VISUAL_STUDIO_PATH_0% +goto build ) -call Paths.cmd -"%VISUAL_STUDIO_PATH%" /p:Configuration=Release +if exist %VISUAL_STUDIO_PATH_1% ( +set VISUAL_STUDIO_PATH=%VISUAL_STUDIO_PATH_1% +goto build +) + +if exist %VISUAL_STUDIO_PATH_2% ( +set VISUAL_STUDIO_PATH=%VISUAL_STUDIO_PATH_2% +goto build +) + +if exist %VISUAL_STUDIO_PATH_3% ( +set VISUAL_STUDIO_PATH=%VISUAL_STUDIO_PATH_3% +goto build +) + +REM No default path found. Let the user know what to do. +echo No Visual Studio installation found. Please configure it manually. +echo 1. Copy 'Paths.cmd.template'. +echo 2. Rename it to 'Paths.cmd'. +echo 3. Enter your Visual Studio path in there. +echo 4. Restart the build. +REM Allow disabling pause to support non-interacting build chains. +if NOT "%~1"=="-no-pause" pause +goto end +) + +:build +REM Log the used Vistual Studio version. +@echo on +%VISUAL_STUDIO_PATH% /p:Configuration=Release +@echo off -:exit +:end popd @echo on diff --git a/Paths.cmd.template b/Paths.cmd.template index d05068b..f2c2acf 100644 --- a/Paths.cmd.template +++ b/Paths.cmd.template @@ -1,12 +1,4 @@ @echo off -:: Set your Visual Studio path here. -:: TODO: Make visual studio path auto detection. - -:: Enterprise path -SET VISUAL_STUDIO_PATH=%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe - -:: Community path -::SET VISUAL_STUDIO_PATH=%programfiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe - -echo Using Visual Studio path:%VISUAL_STUDIO_PATH% +REM Set your Visual Studio path here. +SET VISUAL_STUDIO_PATH="%programfiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe" @echo on \ No newline at end of file