feat(CI): 添加 NuGet 安装脚本并优化 CI 流程
添加三个 NuGet 安装脚本(批处理和 PowerShell),支持直接下载和通过 Chocolatey 安装 修改 CI 工作流,优先使用 Chocolatey 安装 NuGet 并更新 PATH 路径
This commit is contained in:
+17
-16
@@ -238,26 +238,27 @@ jobs:
|
||||
$nugetPath = Get-Command nuget -ErrorAction SilentlyContinue
|
||||
if ($nugetPath) {
|
||||
Write-Host "NuGet already installed: $($nugetPath.Source)"
|
||||
$nugetVersion = nuget help | Select-String -Pattern "NuGet Version" | Select-Object -First 1
|
||||
Write-Host "NuGet version: $nugetVersion"
|
||||
return
|
||||
}
|
||||
|
||||
# Download NuGet CLI
|
||||
Write-Host "Downloading NuGet CLI..."
|
||||
try {
|
||||
Invoke-WebRequest -Uri "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile "C:\nuget.exe" -TimeoutSec 120
|
||||
} catch {
|
||||
Write-Host "Download failed, trying alternative..."
|
||||
# Try alternative download
|
||||
Invoke-WebRequest -Uri "https://dist.nuget.org/win-x86-commandline/v6.7.0/nuget.exe" -OutFile "C:\nuget.exe" -TimeoutSec 120
|
||||
}
|
||||
# Use Chocolatey to install NuGet (proven to work)
|
||||
Write-Host "Installing NuGet via Chocolatey..."
|
||||
choco install nuget.commandline -y
|
||||
|
||||
# Add to PATH
|
||||
$env:PATH = "C:\;$env:PATH"
|
||||
Add-Content -Path $env:GITHUB_PATH -Value "C:\"
|
||||
# Update PATH to include Chocolatey
|
||||
$env:PATH = "C:\ProgramData\chocolatey\bin;$env:PATH"
|
||||
Add-Content -Path $env:GITHUB_PATH -Value "C:\ProgramData\chocolatey\bin"
|
||||
|
||||
# Verify installation
|
||||
$nugetVersion = C:\nuget.exe help | Select-String -Pattern "NuGet Version" | Select-Object -First 1
|
||||
Write-Host "NuGet installed: $nugetVersion"
|
||||
if (Get-Command nuget -ErrorAction SilentlyContinue) {
|
||||
Write-Host "NuGet installed successfully via Chocolatey"
|
||||
$nugetVersion = nuget help | Select-String -Pattern "NuGet Version" | Select-Object -First 1
|
||||
Write-Host "NuGet version: $nugetVersion"
|
||||
} else {
|
||||
Write-Host "WARNING: NuGet installation may have failed, but continuing..."
|
||||
}
|
||||
|
||||
- name: Fix long paths
|
||||
shell: powershell
|
||||
@@ -293,13 +294,13 @@ jobs:
|
||||
- name: Build Windows Debug
|
||||
shell: powershell
|
||||
run: |
|
||||
$env:PATH = "C:\flutter\bin;C:\;$env:PATH"
|
||||
$env:PATH = "C:\flutter\bin;C:\ProgramData\chocolatey\bin;$env:PATH"
|
||||
flutter build windows
|
||||
|
||||
- name: Build Windows Release
|
||||
shell: powershell
|
||||
run: |
|
||||
$env:PATH = "C:\flutter\bin;C:\;$env:PATH"
|
||||
$env:PATH = "C:\flutter\bin;C:\ProgramData\chocolatey\bin;$env:PATH"
|
||||
flutter build windows --release
|
||||
|
||||
- name: Upload Debug build artifacts
|
||||
|
||||
Reference in New Issue
Block a user