Skip to content

Commit c92d44c

Browse files
authored
Add dotnet-local scripts to make using in tree dotnet easier. (dotnet#16461)
* Add `dotnet-local` scripts to make using in tree dotnet easier. Using `dotnet` may require setting `%PATH%` to prefer `bin\dotnet\dotnet` over any other `dotnet` in `%PATH%`. Usage: # Unix path/to/maui/dotnet-local.sh build App.sln rem Windows path\to\maui\dotnet-local.cmd build App.sln If MAUI hasn't been built yet, an error message stating that `build.sh` or `build.ps1` should be executed is printed. * Update error message when MAUI hasn't been built yet. * Update docs.
1 parent 813ce6d commit c92d44c

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

.github/DEVELOPMENT.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,12 @@ public static int foo = 2130771968;
190190

191191
# Advanced Scenarios
192192

193-
### Compile using a local `bin\dotnet`
193+
### Compile using a local `bin\dotnet` via `dotnet-local.*`
194194

195195
This method will use the .NET and workload versions that are specific to the branch you are on, which is a good way to ensure compatibility.
196196

197+
Use `dotnet-local.cmd` on Windows or `dotnet-local.sh` on Unix to ensure that `PATH` is set consistently.
198+
197199
#### Cake
198200

199201
You can run a `Cake` target to bootstrap .NET SDK in `bin\dotnet` and launch Visual Studio:

dotnet-local.cmd

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@echo off
2+
SET ROOT=%~dp0
3+
IF EXIST "%ROOT%\bin\dotnet\dotnet.exe" (
4+
SET DOTNET_ROOT=%ROOT%\bin\dotnet
5+
SET PATH=%DOTNET_ROOT%;%PATH%
6+
call "%ROOT%\bin\dotnet\dotnet.exe" %*
7+
) ELSE (
8+
echo "You must build MAUI first. Please see '.github/DEVELOPMENT.md' for details."
9+
)

dotnet-local.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
ROOT="$(dirname "${BASH_SOURCE}")"
3+
FULLROOT="$(cd "${ROOT}"; pwd)"
4+
5+
if [[ ! -x "${ROOT}/bin/dotnet/dotnet" ]] ; then
6+
echo 'You must build MAUI first. Please see `.github/DEVELOPMENT.md` for details.' 1>&2
7+
exit 1
8+
fi
9+
10+
export DOTNET_ROOT="${FULLROOT}/bin/dotnet"
11+
export PATH="${DOTNET_ROOT}:${PATH}"
12+
exec "${ROOT}/bin/dotnet/dotnet" "$@"

0 commit comments

Comments
 (0)