Skip to content
Open
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
38 changes: 4 additions & 34 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Param(
[ValidateSet("windows","linux","osx")][string]$os,
[switch]$testnobuild,
[ValidateSet("x86","x64","arm","arm64")][string[]][Alias('a')]$arch = @([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant()),
[switch]$mauirestore,

[Parameter(ValueFromRemainingArguments=$true)][String[]]$properties
)
Expand Down Expand Up @@ -36,6 +37,7 @@ function Get-Help() {
Write-Host " This assumes -build has been run already."
Write-Host " -rebuild Rebuild all source projects."
Write-Host " -restore Restore dependencies."
Write-Host " -mauirestore Restore dependencies and install MAUI workload (only on Windows/macOS)."
Write-Host " -sign Sign build outputs."
Write-Host " -test (-t) Incrementally builds and runs tests."
Write-Host " Use in conjunction with -testnobuild to only run tests."
Expand All @@ -44,7 +46,6 @@ function Get-Help() {
Write-Host "Libraries settings:"
Write-Host " -testnobuild Skip building tests when invoking -test."
Write-Host " -buildExtension Build the VS Code extension."
Write-Host " -restore-maui Restore the MAUI workload after restore (only on Windows/macOS)."
Write-Host ""

Write-Host "Command-line arguments not listed above are passed through to MSBuild."
Expand Down Expand Up @@ -100,6 +101,7 @@ foreach ($argument in $PSBoundParameters.Keys)
"arch" { $arguments += " /p:TargetArchitecture=$($PSBoundParameters[$argument])" }
"testnobuild" { $arguments += " /p:VSTestNoBuild=true" }
"buildExtension" { $arguments += " /p:BuildExtension=true" }
"mauirestore" { $arguments += " -restoreMaui" }
default { $arguments += " /p:$argument=$($PSBoundParameters[$argument])" }
}
}
Expand All @@ -110,36 +112,4 @@ if ($env:TreatWarningsAsErrors -eq 'false') {

Write-Host "& `"$PSScriptRoot/common/build.ps1`" $arguments"
Invoke-Expression "& `"$PSScriptRoot/common/build.ps1`" $arguments"
$buildExitCode = $LASTEXITCODE

# Install MAUI workload after restore if -restore-maui was passed
# Only on Windows and macOS (MAUI doesn't support Linux)
$restoreMauiPassed = $properties -contains "-restore-maui"
$isWindowsOrMac = ($IsWindows -or $IsMacOS -or (-not (Get-Variable -Name IsWindows -ErrorAction SilentlyContinue)))
if ($restoreMauiPassed -and $buildExitCode -eq 0 -and $isWindowsOrMac) {
Write-Host ""
Write-Host "Installing MAUI workload into local .dotnet..."

$repoRoot = Split-Path $PSScriptRoot -Parent
$dotnetRoot = Join-Path $repoRoot ".dotnet"
$dotnetExe = Join-Path $dotnetRoot "dotnet.exe"

if (Test-Path $dotnetExe) {
$env:DOTNET_ROOT = $dotnetRoot
$env:PATH = "$dotnetRoot;$env:PATH"

& $dotnetExe workload install maui 2>&1 | Out-Host
if ($LASTEXITCODE -ne 0) {
Write-Host ""
Write-Warning "Failed to install MAUI workload. You may need to run this command manually:"
Write-Warning " $dotnetExe workload install maui"
Write-Host ""
Write-Host "The MAUI playground may not work without the MAUI workload installed."
}
else {
Write-Host "MAUI workload installed successfully."
}
}
}

exit $buildExitCode
exit $LASTEXITCODE
39 changes: 4 additions & 35 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ usage()
echo " This assumes --build has been run already."
echo " --rebuild Rebuild all source projects."
echo " --restore (-r) Restore dependencies."
echo " --mauirestore Restore dependencies and install MAUI workload (only on macOS)."
echo " --sign Sign build outputs."
echo " --test (-t) Incrementally builds and runs tests."
echo " Use in conjunction with --testnobuild to only run tests."
Expand All @@ -46,7 +47,6 @@ usage()
echo "Libraries settings:"
echo " --testnobuild Skip building tests when invoking -test."
echo " --build-extension Build the VS Code extension."
echo " --restore-maui Restore the MAUI workload after restore (only on macOS)."
echo ""

echo "Command line arguments starting with '/p:' are passed through to MSBuild."
Expand All @@ -56,7 +56,6 @@ usage()

arguments=''
extraargs=''
restore_maui=false

# Check if an action is passed in
declare -a actions=("b" "build" "r" "restore" "rebuild" "testnobuild" "sign" "publish" "clean" "t" "test" "build-extension")
Expand Down Expand Up @@ -144,8 +143,8 @@ while [[ $# > 0 ]]; do
shift 1
;;

-restore-maui)
restore_maui=true
-mauirestore)
extraargs="$extraargs -restoreMaui"
shift 1
;;

Expand All @@ -166,35 +165,5 @@ fi

arguments="$arguments $extraargs"
"$scriptroot/common/build.sh" $arguments
buildExitCode=$?

# Install MAUI workload after restore if --restore-maui was passed
# Only on macOS (MAUI doesn't support Linux, Windows uses .cmd)
if [ "$restore_maui" = true ] && [ $buildExitCode -eq 0 ]; then
# Check if we're on macOS
if [[ "$(uname -s)" == "Darwin" ]]; then
echo ""
echo "Installing MAUI workload into local .dotnet..."

repo_root="$(cd "$scriptroot/.." && pwd)"
dotnet_root="$repo_root/.dotnet"
dotnet_exe="$dotnet_root/dotnet"

if [ -f "$dotnet_exe" ]; then
export DOTNET_ROOT="$dotnet_root"
export PATH="$dotnet_root:$PATH"

if "$dotnet_exe" workload install maui; then
echo "MAUI workload installed successfully."
else
echo ""
echo "WARNING: Failed to install MAUI workload. You may need to run this command manually:"
echo " $dotnet_exe workload install maui"
echo ""
echo "The MAUI playground may not work without the MAUI workload installed."
fi
fi
fi
fi

exit $buildExitCode
exit $?
2 changes: 2 additions & 0 deletions eng/common/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Param(
[string] $runtimeSourceFeedKey = '',
[switch] $excludePrereleaseVS,
[switch] $nativeToolsOnMachine,
[switch] $restoreMaui,
[switch] $help,
[Parameter(ValueFromRemainingArguments=$true)][String[]]$properties
)
Expand Down Expand Up @@ -76,6 +77,7 @@ function Print-Usage() {
Write-Host " -nodeReuse <value> Sets nodereuse msbuild parameter ('true' or 'false')"
Write-Host " -buildCheck Sets /check msbuild parameter"
Write-Host " -fromVMR Set when building from within the VMR"
Write-Host " -restoreMaui Restore the MAUI workload after restore (only on Windows/macOS)"
Write-Host ""

Write-Host "Command line arguments not listed above are passed thru to msbuild."
Expand Down
5 changes: 5 additions & 0 deletions eng/common/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ usage()
echo " --warnAsError <value> Sets warnaserror msbuild parameter ('true' or 'false')"
echo " --buildCheck <value> Sets /check msbuild parameter"
echo " --fromVMR Set when building from within the VMR"
echo " --restoreMaui Restore the MAUI workload after restore (only on macOS)"
echo ""
echo "Command line arguments not listed above are passed thru to msbuild."
echo "Arguments can also be passed in with a single hyphen."
Expand Down Expand Up @@ -76,6 +77,7 @@ sign=false
public=false
ci=false
clean=false
restore_maui=false

warn_as_error=true
node_reuse=true
Expand Down Expand Up @@ -183,6 +185,9 @@ while [[ $# -gt 0 ]]; do
-buildcheck)
build_check=true
;;
-restoremaui|-restore-maui)
restore_maui=true
;;
-runtimesourcefeed)
runtime_source_feed=$2
shift
Expand Down
33 changes: 33 additions & 0 deletions eng/restore-toolset.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Install MAUI workload if -restoreMaui was passed
# Only on Windows and macOS (MAUI doesn't support Linux)

if ($restoreMaui) {
$isWindowsOrMac = ($IsWindows -or $IsMacOS -or (-not (Get-Variable -Name IsWindows -ErrorAction SilentlyContinue)))

if ($isWindowsOrMac) {
Write-Host "Installing MAUI workload..."

$dotnetCmd = if ($IsWindows -or (-not (Get-Variable -Name IsWindows -ErrorAction SilentlyContinue))) {
Join-Path $RepoRoot "dotnet.cmd"
} else {
Join-Path $RepoRoot "dotnet.sh"
}

& $dotnetCmd workload install maui 2>&1 | Out-Host
if ($LASTEXITCODE -ne 0) {
Write-Host ""
Write-Warning "Failed to install MAUI workload. You may need to run this command manually:"
Write-Warning " $dotnetCmd workload install maui"
Write-Host ""
Write-Host "The MAUI playground may not work without the MAUI workload installed."
Write-Host ""
}
else {
Write-Host "MAUI workload installed successfully."
Write-Host ""
}
}
else {
Write-Host "Skipping MAUI workload installation on Linux (not supported)."
}
}
28 changes: 28 additions & 0 deletions eng/restore-toolset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

# Install MAUI workload if -restoreMaui was passed
# Only on macOS (MAUI doesn't support Linux, Windows uses .cmd)

if [[ "$restore_maui" == true ]]; then
# Check if we're on macOS
if [[ "$(uname -s)" == "Darwin" ]]; then
echo ""
echo "Installing MAUI workload..."

dotnet_sh="$repo_root/dotnet.sh"

if "$dotnet_sh" workload install maui; then
echo "MAUI workload installed successfully."
echo ""
else
echo ""
echo "WARNING: Failed to install MAUI workload. You may need to run this command manually:"
echo " $dotnet_sh workload install maui"
echo ""
echo "The MAUI playground may not work without the MAUI workload installed."
echo ""
fi
else
echo "Skipping MAUI workload installation on Linux (not supported)."
fi
fi
18 changes: 9 additions & 9 deletions playground/AspireWithMaui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ Run the following commands from the repository root:

**Windows:**
```cmd
.\restore.cmd -restore-maui
.\restore.cmd -mauirestore
```

**Linux/macOS:**
```bash
./restore.sh --restore-maui
./restore.sh --mauirestore
```

This will:
Expand All @@ -34,22 +34,22 @@ This will:

### Running the Playground

After running the restore script with `-restore-maui`, you can build and run the playground:
After running the restore script with `-mauirestore`, you can build and run the playground:

**Using Visual Studio:**
1. Run `.\restore.cmd -restore-maui` from the repository root (Windows)
1. Run `.\restore.cmd -mauirestore` from the repository root (Windows)
2. Open `AspireWithMaui.AppHost` project
3. Set it as the startup project
4. Press F5 to run

**Using VS Code:**
1. Run `.\restore.cmd -restore-maui` (Windows) or `./restore.sh --restore-maui` (Linux/macOS) from the repository root
1. Run `.\restore.cmd -mauirestore` (Windows) or `./restore.sh --mauirestore` (Linux/macOS) from the repository root
2. From the repository root, run: `./start-code.sh` or `start-code.cmd`
3. Open the `AspireWithMaui` folder
4. Use the debugger to run the AppHost

**Using Command Line:**
1. Run `.\restore.cmd -restore-maui` (Windows) or `./restore.sh --restore-maui` (Linux/macOS) from the repository root
1. Run `.\restore.cmd -mauirestore` (Windows) or `./restore.sh --mauirestore` (Linux/macOS) from the repository root
2. Navigate to `playground/AspireWithMaui/AspireWithMaui.AppHost` directory
3. Run: `dotnet run`

Expand Down Expand Up @@ -86,13 +86,13 @@ The architecture is designed to support additional platforms (Android, iOS) thro

### "MAUI workload not detected" Warning
If you see this warning in the Aspire dashboard:
1. Make sure you ran `.\restore.cmd -restore-maui` or `./restore.sh --restore-maui` from the repository root
1. Make sure you ran `.\restore.cmd -mauirestore` or `./restore.sh --mauirestore` from the repository root
2. The warning indicates the MAUI workload is not installed in the local `.dotnet` folder
3. Re-run the restore command with the `-restore-maui` or `--restore-maui` flag
3. Re-run the restore command with the `-mauirestore` or `--mauirestore` flag

### Build Errors
If you encounter build errors:
1. Ensure you ran the restore script with the MAUI flag first: `.\restore.cmd -restore-maui`
1. Ensure you ran the restore script with the MAUI flag first: `.\restore.cmd -mauirestore`
2. Make sure you're using .NET 10 RC or later
3. Try running `dotnet build` from the repository root first

Expand Down