diff --git a/scripts/prepare-runtime-donors.ps1 b/scripts/prepare-runtime-donors.ps1 index 0d52f2a..0173020 100644 --- a/scripts/prepare-runtime-donors.ps1 +++ b/scripts/prepare-runtime-donors.ps1 @@ -10,6 +10,34 @@ $ErrorActionPreference = 'Stop' $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path $repoRoot = Split-Path -Parent $scriptDir . "$scriptDir/_exec.ps1" + +# Resolve dotnet the same way ilspycmd is resolved below: prefer one on PATH, +# then fall back to the user-profile install at ~/.dotnet. The installer and +# bootstrap can place the SDK under %USERPROFILE%\.dotnet without adding it to +# PATH, so a bare "dotnet" call from here found no SDK and the donor build died +# with "No .NET SDKs were found" (issue #90). When the resolved dotnet lives in +# the profile install, DOTNET_ROOT has to point at it so the host discovers the +# SDK there, matching what IlspycmdInstaller.cs does for the tool it spawns. +$dotnetCmd = Get-Command dotnet -ErrorAction SilentlyContinue +if ($dotnetCmd) { + $dotnetPath = $dotnetCmd.Source +} else { + $profileRoot = if ($env:USERPROFILE) { $env:USERPROFILE } else { $env:HOME } + $dotnetPath = Join-Path $profileRoot '.dotnet/dotnet.exe' + if (-not (Test-Path $dotnetPath)) { + $dotnetPath = Join-Path $profileRoot '.dotnet/dotnet' + } + if (-not (Test-Path $dotnetPath)) { + throw 'dotnet is required. Install the .NET SDK or run scripts/bootstrap.ps1 first.' + } +} +$dotnetDir = Split-Path -Parent $dotnetPath +$profileRootForCheck = if ($env:USERPROFILE) { $env:USERPROFILE } else { $env:HOME } +$profileDotnet = [IO.Path]::GetFullPath((Join-Path $profileRootForCheck '.dotnet')) +if ($dotnetDir -ieq $profileDotnet) { + $env:DOTNET_ROOT = $dotnetDir +} + if (-not $VanillaDir) { $VanillaDir = Join-Path $repoRoot '.vanilla/win-x64/vintagestory' } @@ -367,12 +395,12 @@ Remove-Item Env:Platform -ErrorAction SilentlyContinue $buildErrors = @() try { Write-Host " Building VSEssentials..." - Invoke-NativeStep { & dotnet build $essentialsProject -c $Configuration --nologo } + Invoke-NativeStep { & $dotnetPath build $essentialsProject -c $Configuration --nologo } if ($LASTEXITCODE -ne 0) { $buildErrors += 'VSEssentials' } Write-Host " Building VSSurvivalMod..." - Invoke-NativeStep { & dotnet build $survivalProject -c $Configuration --nologo } + Invoke-NativeStep { & $dotnetPath build $survivalProject -c $Configuration --nologo } if ($LASTEXITCODE -ne 0) { $buildErrors += 'VSSurvivalMod' } diff --git a/scripts/prepare-runtime-donors.sh b/scripts/prepare-runtime-donors.sh index bca3d54..f6f3873 100644 --- a/scripts/prepare-runtime-donors.sh +++ b/scripts/prepare-runtime-donors.sh @@ -11,6 +11,27 @@ vanilla_parent="$(cd -- "$vanilla_dir/.." && pwd)" runtime_donor_dir="${RUNTIME_DONOR_DIR:-$vanilla_parent/runtime-donors}" configuration="${CONFIGURATION:-Release}" runtime_root="$repo_root/.build/runtime-donors" + +# Resolve dotnet the same way the PowerShell mirror does: prefer one on PATH, +# then fall back to the user-profile install at ~/.dotnet. The installer and +# bootstrap can place the SDK under $HOME/.dotnet without adding it to PATH, so +# a bare "dotnet" call from here found no SDK and the donor build died with +# "No .NET SDKs were found" (issue #90). When the resolved dotnet lives in the +# profile install, DOTNET_ROOT has to point at it so the host discovers the SDK +# there. +if command -v dotnet >/dev/null 2>&1; then + dotnet_cmd="$(command -v dotnet)" +elif [[ -x "$HOME/.dotnet/dotnet" ]]; then + dotnet_cmd="$HOME/.dotnet/dotnet" +else + echo "dotnet is required. Install the .NET SDK or run scripts/bootstrap.sh first." >&2 + exit 1 +fi +dotnet_dir="$(cd -- "$(dirname -- "$dotnet_cmd")" && pwd)" +if [[ "$dotnet_dir" == "$HOME/.dotnet" ]]; then + export DOTNET_ROOT="$dotnet_dir" +fi + contracts_dll="$repo_root/bin/$configuration/net10.0/Optimum.Api.Contracts.dll" game_content_dll="$repo_root/bin/$configuration/net10.0/Optimum.GameContent.dll" api_dll="$repo_root/bin/$configuration/net10.0/VintagestoryAPI.dll" @@ -350,13 +371,13 @@ unset Platform build_errors="" if [[ " ${eligible_projects[*]} " == *" VSEssentials "* ]]; then echo " Building VSEssentials..." - if ! dotnet build "$essentials_project" -c "$configuration" --nologo; then + if ! "$dotnet_cmd" build "$essentials_project" -c "$configuration" --nologo; then build_errors="${build_errors}VSEssentials " fi fi if [[ " ${eligible_projects[*]} " == *" VSSurvivalMod "* ]]; then echo " Building VSSurvivalMod..." - if ! dotnet build "$survival_project" -c "$configuration" --nologo; then + if ! "$dotnet_cmd" build "$survival_project" -c "$configuration" --nologo; then build_errors="${build_errors}VSSurvivalMod " fi fi