@@ -34,99 +34,13 @@ Write-Host 'Detected Windows host. Building Windows desktop app...'
3434Write-Host " Version: $buildName +$buildNumber "
3535Write-Host " Flutter: $flutter "
3636
37- $windowsBuildDir = Join-Path $repoRoot ' build\windows\x64'
38- $buildNugetConfig = Join-Path $windowsBuildDir ' NuGet.Config'
39- New-Item - ItemType Directory - Force - Path $windowsBuildDir | Out-Null
40- $nugetConfigText = @'
41- <?xml version="1.0" encoding="utf-8"?>
42- <configuration>
43- <packageSources>
44- <clear />
45- <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
46- </packageSources>
47- </configuration>
48- '@
49- Set-Content - LiteralPath $buildNugetConfig - Value $nugetConfigText - Encoding utf8
50- Write-Host " NuGet config: $buildNugetConfig "
51-
52- $pathNuget = Get-Command ' nuget.exe' - ErrorAction SilentlyContinue
53- $nugetDir = Join-Path $repoRoot ' build\tools\nuget'
54- $nugetExe = Join-Path $nugetDir ' nuget.exe'
55-
56- if ($pathNuget ) {
57- $nugetExe = $pathNuget.Source
58- $nugetDir = Split-Path - Parent $nugetExe
59- }
60- else {
61- New-Item - ItemType Directory - Force - Path $nugetDir | Out-Null
62- if (-not (Test-Path - LiteralPath $nugetExe )) {
63- $existingNuget = Get-ChildItem - Path $windowsBuildDir - Recurse - Filter ' nuget.exe' - ErrorAction SilentlyContinue |
64- Select-Object - First 1
65-
66- if ($existingNuget ) {
67- Copy-Item - LiteralPath $existingNuget.FullName - Destination $nugetExe - Force
68- }
69- else {
70- $nugetUrl = ' https://dist.nuget.org/win-x86-commandline/v6.5.0/nuget.exe'
71- Write-Host " Downloading NuGet: $nugetUrl "
72- [Net.ServicePointManager ]::SecurityProtocol = [Net.SecurityProtocolType ]::Tls12
73- Invoke-WebRequest - Uri $nugetUrl - OutFile $nugetExe
74- }
75- }
76-
77- $env: PATH = " $nugetDir ;$env: PATH "
78- }
79-
80- Write-Host " NuGet executable: $nugetExe "
81-
8237if ($args -contains ' --dry-run' ) {
8338 Write-Host ' '
8439 Write-Host ' Dry run only. Command that would be executed:'
8540 Write-Host " `" $flutter `" build windows --release --build-name `" $buildName `" --build-number `" $buildNumber `" "
8641 exit 0
8742}
8843
89- $vswhere = Join-Path ${env: ProgramFiles(x86)} ' Microsoft Visual Studio\Installer\vswhere.exe'
90- $vsInstallPath = $null
91- if (Test-Path - LiteralPath $vswhere ) {
92- $vsInstallPath = (& $vswhere - products * - latest - requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 - property installationPath).Trim()
93- }
94-
95- if (-not $vsInstallPath ) {
96- Write-Host ' '
97- Write-Host ' Visual Studio Build Tools with C++ support was not found.'
98- Write-Host ' Install Visual Studio 2022 Build Tools with the Desktop development with C++ workload, then run this script again.'
99- exit 1
100- }
101-
102- $msvcToolsRoot = Join-Path $vsInstallPath ' VC\Tools\MSVC'
103- $hasAtlHeaders = $false
104- if (Test-Path - LiteralPath $msvcToolsRoot ) {
105- Get-ChildItem - LiteralPath $msvcToolsRoot - Directory - ErrorAction SilentlyContinue | ForEach-Object {
106- $atlBase = Join-Path $_.FullName ' atlmfc\include\atlbase.h'
107- $atlStr = Join-Path $_.FullName ' atlmfc\include\atlstr.h'
108- if ((Test-Path - LiteralPath $atlBase ) -and (Test-Path - LiteralPath $atlStr )) {
109- $hasAtlHeaders = $true
110- }
111- }
112- }
113-
114- if (-not $hasAtlHeaders ) {
115- $vsInstaller = Join-Path ${env: ProgramFiles(x86)} ' Microsoft Visual Studio\Installer\vs_installer.exe'
116- if (-not (Test-Path - LiteralPath $vsInstaller )) {
117- $vsInstaller = Join-Path ${env: ProgramFiles(x86)} ' Microsoft Visual Studio\Installer\setup.exe'
118- }
119-
120- Write-Host ' '
121- Write-Host ' Visual Studio Build Tools is missing ATL headers required by Windows plugins.'
122- Write-Host ' Missing headers: atlbase.h, atlstr.h'
123- Write-Host ' Install the "C++ ATL for latest v143 build tools" component, then run this script again.'
124- Write-Host ' '
125- Write-Host ' Elevated PowerShell/CMD command:'
126- Write-Host " `" $vsInstaller `" modify --installPath `" $vsInstallPath `" --add Microsoft.VisualStudio.Component.VC.ATL --passive --norestart"
127- exit 1
128- }
129-
13044& $flutter build windows -- release -- build-name $buildName -- build-number $buildNumber
13145if ($LASTEXITCODE -ne 0 ) {
13246 exit $LASTEXITCODE
0 commit comments