Skip to content

Added a Paths.cmd template so users can add their local VisualStudio … #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,4 @@ ASALocalRun/

# MFractors (Xamarin productivity tool) working folder
.mfractor/
/Paths.cmd
52 changes: 50 additions & 2 deletions Build.cmd
Original file line number Diff line number Diff line change
@@ -1,11 +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

"%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" /p:Configuration=Release
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
)

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
4 changes: 4 additions & 0 deletions Paths.cmd.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
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