Signed-off-by: Shawn Yuan (from Dev Box) <shuaiyuan@microsoft.com>
This commit is contained in:
Shawn Yuan (from Dev Box)
2025-12-09 15:43:35 +08:00
parent 64be0d36e9
commit 1ab41f4ea3
2 changed files with 7 additions and 21 deletions

View File

@@ -95,13 +95,11 @@ if ($WinAppSDKVersion -match "^1\.8") {
$installDir = Join-Path $rootPath "localpackages\output" $installDir = Join-Path $rootPath "localpackages\output"
New-Item -ItemType Directory -Path $installDir -Force | Out-Null New-Item -ItemType Directory -Path $installDir -Force | Out-Null
# Create a temporary nuget.config to avoid interference from the repo's config $nugetConfig = Join-Path $rootPath "nuget.config"
$tempConfig = Join-Path $env:TEMP "nuget_$(Get-Random).config"
Set-Content -Path $tempConfig -Value "<?xml version='1.0' encoding='utf-8'?><configuration><packageSources><clear /><add key='TempSource' value='$sourceLink' /></packageSources></configuration>"
try { try {
# Download package to inspect nuspec and keep it for the build # Download package to inspect nuspec and keep it for the build
$nugetArgs = "install Microsoft.WindowsAppSDK -Version $WinAppSDKVersion -ConfigFile $tempConfig -OutputDirectory $installDir -NonInteractive -NoCache" $nugetArgs = "install Microsoft.WindowsAppSDK -Version $WinAppSDKVersion -ConfigFile ""$nugetConfig"" -OutputDirectory $installDir -NonInteractive -NoCache"
Invoke-Expression "nuget $nugetArgs" | Out-Null Invoke-Expression "nuget $nugetArgs" | Out-Null
# Parse dependencies from the installed folders # Parse dependencies from the installed folders
@@ -117,8 +115,6 @@ if ($WinAppSDKVersion -match "^1\.8") {
} }
} catch { } catch {
Write-Warning "Failed to resolve dependencies: $_" Write-Warning "Failed to resolve dependencies: $_"
} finally {
Remove-Item $tempConfig -Force -ErrorAction SilentlyContinue
} }
} }
@@ -151,5 +147,10 @@ Get-ChildItem -Path $rootPath -Recurse "Directory.Packages.props" | ForEach-Obje
} }
} }
if ($installDir -and (Test-Path $installDir)) {
Write-Host "Cleaning up installed packages..."
Remove-Item -Path $installDir -Recurse -Force
}

View File

@@ -19,21 +19,6 @@ steps:
-useExperimentalVersion $${{ parameters.useExperimentalVersion }} -useExperimentalVersion $${{ parameters.useExperimentalVersion }}
-rootPath "$(build.sourcesdirectory)" -rootPath "$(build.sourcesdirectory)"
- script: echo $(WinAppSDKVersion)
displayName: 'Display WinAppSDK Version Found'
- task: NuGetAuthenticate@1
displayName: 'NuGet Authenticate'
- task: NuGetCommand@2
displayName: 'Restore NuGet packages'
inputs:
command: 'restore'
feedsToUse: 'config'
nugetConfigPath: '$(build.sourcesdirectory)\nuget.config'
restoreSolution: '$(build.sourcesdirectory)\**\*.sln'
includeNuGetOrg: false
- task: NuGetCommand@2 - task: NuGetCommand@2
displayName: 'Restore NuGet packages (slnx)' displayName: 'Restore NuGet packages (slnx)'
inputs: inputs: