ci(workflows): 添加Windows构建修复步骤到CI流程
Build Windows / 编译 libcore (Windows) (20.15.1) (push) Successful in 19m37s
Build Windows / build (push) Failing after 7h1m43s

添加NuGet安装、长路径支持、清理构建缓存等步骤
确保Windows环境下的Flutter构建能够成功执行
This commit is contained in:
2025-11-08 23:50:07 -08:00
parent 50f4237c74
commit 8cc88be5f6
2 changed files with 127 additions and 2 deletions
+63 -2
View File
@@ -229,16 +229,77 @@ jobs:
$env:PATH = "C:\flutter\bin;$env:PATH"
dart run build_runner build --delete-conflicting-outputs
- name: Build Windows Debug
- name: Install NuGet
shell: powershell
run: |
Write-Host "Installing NuGet..."
# Check if NuGet is already available
$nugetPath = Get-Command nuget -ErrorAction SilentlyContinue
if ($nugetPath) {
Write-Host "NuGet already installed: $($nugetPath.Source)"
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
}
# Add to PATH
$env:PATH = "C:\;$env:PATH"
Add-Content -Path $env:GITHUB_PATH -Value "C:\"
# Verify installation
$nugetVersion = C:\nuget.exe help | Select-String -Pattern "NuGet Version" | Select-Object -First 1
Write-Host "NuGet installed: $nugetVersion"
- name: Fix long paths
shell: powershell
run: |
Write-Host "Enabling long path support..."
# Enable long paths in Windows
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -Type DWORD -Force
# Also set for current user
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\AppModel\StateRepository\Cache\Package\Data\" -Name "LongPathsEnabled" -Value 1 -Type DWORD -Force -ErrorAction SilentlyContinue
Write-Host "Long path support enabled"
- name: Clean build cache
shell: powershell
run: |
$env:PATH = "C:\flutter\bin;$env:PATH"
Write-Host "Cleaning build cache..."
flutter clean
Write-Host "Removing old build directories..."
if (Test-Path "build") {
Remove-Item -Path "build" -Recurse -Force
}
if (Test-Path "windows") {
Remove-Item -Path "windows" -Recurse -Force
}
Write-Host "Recreating Windows project..."
flutter create --platforms=windows .
- name: Build Windows Debug
shell: powershell
run: |
$env:PATH = "C:\flutter\bin;C:\;$env:PATH"
flutter build windows
- name: Build Windows Release
shell: powershell
run: |
$env:PATH = "C:\flutter\bin;$env:PATH"
$env:PATH = "C:\flutter\bin;C:\;$env:PATH"
flutter build windows --release
- name: Upload Debug build artifacts