Skip to content
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

Fix the batch file for running local dotnet on windows #23541

Merged
merged 1 commit into from
Jul 11, 2024
Merged
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
5 changes: 3 additions & 2 deletions dotnet-local.cmd
Original file line number Diff line number Diff line change
@@ -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%"
Comment on lines 4 to +6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vitek-karas do we have any similar problems here?

https://github.com/dotnet/android/blob/main/dotnet-local.cmd

Or is it fine? Because there are not multiple lines inside an IF?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be fine - the problem is that the parser considers the entire IF as one statement and performs env. variable replacement BEFORE it executes the statement. Any changes to the environment are not visible to the statements inside the IF, but they are visible to external tools (so in this case the dotnet.exe will see the new values as expected).

call "%ROOT%\bin\dotnet\dotnet.exe" %*
) ELSE (
echo "You must build MAUI first. Please see '.github/DEVELOPMENT.md' for details."
Expand Down
Loading