From 5288300125e388939ef9908dd133ed0d9b75db93 Mon Sep 17 00:00:00 2001 From: vitek-karas <10670590+vitek-karas@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:54:35 +0200 Subject: [PATCH] Fix the batch file for running local dotnet on windows The problem was that the body of the IF statement is considered one "line" and all environment variables are replaced before that "line" is executed. So set commands don't have an effect on the rest of the code in that IF. Changed this to use `enabledelayedexpansion` and the `!!` syntax which makes it work the way would would expect. One additional fix, enclose the set commands in quotation marks. This fixes a bug where if the `PATH` contains a parenthesis, the script would just plain fail (which can happen if one has x86 programs in their PATH). --- dotnet-local.cmd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dotnet-local.cmd b/dotnet-local.cmd index d1c21fbc0493..24cdebefbe06 100644 --- a/dotnet-local.cmd +++ b/dotnet-local.cmd @@ -1,8 +1,9 @@ @echo off +setlocal enabledelayedexpansion SET ROOT=%~dp0 IF EXIST "%ROOT%\bin\dotnet\dotnet.exe" ( - SET DOTNET_ROOT=%ROOT%\bin\dotnet - SET PATH=%DOTNET_ROOT%;%PATH% + SET "DOTNET_ROOT=%ROOT%\bin\dotnet" + SET "PATH=!DOTNET_ROOT!;%PATH%" call "%ROOT%\bin\dotnet\dotnet.exe" %* ) ELSE ( echo "You must build MAUI first. Please see '.github/DEVELOPMENT.md' for details."