Repository navigation
Enhance ARM64 build scripts and architecture handling #15314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KlausLoeffelmann
wants to merge
3
commits into
dotnet:main
Choose a base branch
from
KlausLoeffelmann:armFix-on-main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+955
−8
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| @echo off | ||
| powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -NativeToolsOnMachine -restore %*" | ||
| powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0eng\build.cmd.ps1" -RestoreOnly %* | ||
| exit /b %ErrorLevel% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| @echo off | ||
| powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -NativeToolsOnMachine -restore -build -bl %*" | ||
| powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0eng\build.cmd.ps1" %* | ||
| exit /b %ErrorLevel% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <Project> | ||
| <!-- Bypass Arcade's directory-only cache checks and x86-only runtime isolation. | ||
| The repository installer uses the SDK muxer architecture, not the OS or target. --> | ||
| <Target Name="InstallWinFormsRuntimes" | ||
| BeforeTargets="InstallDotNetCore" | ||
| Condition="'$(OS)' == 'Windows_NT' and '$(DotNetBuildSourceOnly)' != 'true' and '$(SkipRuntimesInstall)' != 'true'"> | ||
| <PropertyGroup> | ||
| <SkipRuntimesInstall>true</SkipRuntimesInstall> | ||
| <_WinFormsRuntimeRoot>$(DotNetRoot)</_WinFormsRuntimeRoot> | ||
| <_WinFormsRuntimeRoot Condition="'$(DOTNET_GLOBAL_INSTALL_DIR)' != ''">$(DOTNET_GLOBAL_INSTALL_DIR)</_WinFormsRuntimeRoot> | ||
| <_WinFormsRuntimeRootArgument>$(_WinFormsRuntimeRoot)</_WinFormsRuntimeRootArgument> | ||
| <_WinFormsRuntimeRootArgument Condition="$(_WinFormsRuntimeRoot.EndsWith('\'))">$(_WinFormsRuntimeRoot)\</_WinFormsRuntimeRootArgument> | ||
| <_WinFormsRuntimeSourceOptions Condition="'$(DotNetRuntimeSourceFeed)' != ''">-RuntimeSourceFeed "$(DotNetRuntimeSourceFeed)"</_WinFormsRuntimeSourceOptions> | ||
| <_WinFormsRuntimeSourceOptions Condition="'$(DotNetRuntimeSourceFeed)' != '' and '$(DotNetRuntimeSourceFeedKey)' != ''">$(_WinFormsRuntimeSourceOptions) -RuntimeSourceFeedKey "$(DotNetRuntimeSourceFeedKey)"</_WinFormsRuntimeSourceOptions> | ||
| <_WinFormsTargetArchitectureOptions Condition="'$(TargetArchitecture)' != ''">-TargetArchitecture "$(TargetArchitecture)"</_WinFormsTargetArchitectureOptions> | ||
| </PropertyGroup> | ||
|
|
||
| <Exec Command="powershell -NoProfile -ExecutionPolicy Bypass -File "$(RepositoryEngineeringDir)install-runtimes.ps1" -SdkRoot "$(_WinFormsRuntimeRootArgument)" -RuntimeVersion "$(MicrosoftNETCoreAppRefPackageVersion)" $(_WinFormsTargetArchitectureOptions) $(_WinFormsRuntimeSourceOptions)" /> | ||
| </Target> | ||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| $ErrorActionPreference = 'Stop' | ||
| $BuildArgs = @($args) | ||
|
|
||
| try { | ||
| . "$PSScriptRoot\dotnet-architecture.ps1" | ||
| $hostArchitecture = Get-WindowsBuildArchitecture | ||
| $buildScriptPath = "$PSScriptRoot\common\build.ps1" | ||
| $buildParameters = (Get-Command $buildScriptPath).Parameters.Values | ||
|
|
||
| function Get-ArcadeParameter([string] $argument) { | ||
| if ($argument -notmatch '^-(?<Name>[A-Za-z]+)(:.*)?$') { | ||
| return | ||
| } | ||
|
|
||
| $name = $Matches.Name | ||
| $parameters = @($buildParameters | Where-Object { $_.Name -eq $name -or $_.Aliases -contains $name }) | ||
| if ($parameters.Count -eq 0) { | ||
| $parameters = @($buildParameters | Where-Object { | ||
| $names = @($_.Name) + @($_.Aliases) | ||
| @($names | Where-Object { $_.StartsWith($name, [StringComparison]::OrdinalIgnoreCase) }).Count -gt 0 | ||
| }) | ||
| } | ||
|
|
||
| if ($parameters.Count -eq 1) { | ||
| return $parameters[0] | ||
| } | ||
| } | ||
|
|
||
| $forwardArgs = [System.Collections.Generic.List[string]]::new() | ||
| $platform = $null | ||
| $propertyPlatform = $null | ||
| $hasPropertyPlatform = $false | ||
| $hasTargetArchitecture = $false | ||
| $hasRestore = $false | ||
| $hasBuild = $false | ||
| $hasBinaryLog = $false | ||
| $restoreOnly = $false | ||
|
|
||
| for ($i = 0; $i -lt $BuildArgs.Length; $i++) { | ||
| $arg = $BuildArgs[$i] | ||
| if ($arg -eq '-RestoreOnly') { | ||
| $restoreOnly = $true | ||
| continue | ||
| } | ||
|
|
||
| if ($arg -match '^[-/](p|property):(.+)$') { | ||
| $propertyList = $Matches[2] | ||
| foreach ($property in [regex]::Matches($propertyList, '(?:^|;)\s*(?<Name>[^=;]+)=(?<Value>(?:"[^"]*"|[^;"])*)')) { | ||
| switch ($property.Groups['Name'].Value.Trim()) { | ||
| 'TargetArchitecture' { $hasTargetArchitecture = $true } | ||
| 'Platform' { | ||
| $propertyPlatform = $property.Groups['Value'].Value.Trim().Trim('"') | ||
| $hasPropertyPlatform = $true | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| $parameter = Get-ArcadeParameter $arg | ||
| if ($parameter.Name -eq 'restore') { $hasRestore = $true } | ||
| if ($parameter.Name -eq 'build') { $hasBuild = $true } | ||
| if ($parameter.Name -in @('binaryLog', 'binaryLogName', 'excludeCIBinarylog')) { $hasBinaryLog = $true } | ||
| if ($parameter.Name -eq 'platform') { | ||
| $parts = $arg.Split(':', 2) | ||
| if ($parts.Length -eq 2) { $platform = $parts[1] } | ||
| elseif ($i + 1 -lt $BuildArgs.Length) { $platform = $BuildArgs[$i + 1] } | ||
| } | ||
|
|
||
| $forwardArgs.Add($arg) | ||
| } | ||
|
|
||
| if (!$hasTargetArchitecture) { | ||
| # Arcade emits -platform before its remaining MSBuild properties. | ||
| $targetArchitecture = if ($hasPropertyPlatform) { $propertyPlatform } else { $platform } | ||
| if ($targetArchitecture -match '^(arm64|x64|x86)$') { | ||
| $forwardArgs.Add("/p:TargetArchitecture=$($targetArchitecture.ToLowerInvariant())") | ||
| } | ||
| else { | ||
| $forwardArgs.Add("/p:TargetArchitecture=$hostArchitecture") | ||
| } | ||
| } | ||
|
|
||
| if (!$hasRestore) { $forwardArgs.Add('-restore') } | ||
| if (!$restoreOnly -and !$hasBuild) { $forwardArgs.Add('-build') } | ||
| if (!$restoreOnly -and !$hasBinaryLog) { $forwardArgs.Add('-bl') } | ||
|
|
||
| # -File cannot bind Boolean parameters in Windows PowerShell. Encode a command | ||
| # with quoted values and literal Boolean arguments instead of losing their types. | ||
| $buildScript = $buildScriptPath.Replace("'", "''") | ||
| $command = "`$ErrorActionPreference = 'Stop'; `$ProgressPreference = 'SilentlyContinue'; & '$buildScript' -NativeToolsOnMachine" | ||
| for ($i = 0; $i -lt $forwardArgs.Count; $i++) { | ||
| $arg = $forwardArgs[$i] | ||
| $parameter = Get-ArcadeParameter $arg | ||
| $parts = $arg.Split(':', 2) | ||
| if ($parameter.ParameterType -eq [bool] -or | ||
| ($parameter.ParameterType -eq [switch] -and $parts.Length -eq 2)) { | ||
| $value = if ($parts.Length -eq 2) { $parts[1] } else { | ||
| $i++ | ||
| if ($i -ge $forwardArgs.Count) { throw "Missing Boolean value for -$($parameter.Name)." } | ||
| $forwardArgs[$i] | ||
| } | ||
| $separator = if ($parameter.ParameterType -eq [switch]) { ':' } else { ' ' } | ||
| switch ($value.TrimStart('$').ToLowerInvariant()) { | ||
| { $_ -in @('true', '1') } { $command += " -$($parameter.Name)$separator`$true" } | ||
| { $_ -in @('false', '0') } { $command += " -$($parameter.Name)$separator`$false" } | ||
| default { throw "Invalid Boolean value for -$($parameter.Name): $value" } | ||
| } | ||
| } | ||
| elseif ($parameter) { | ||
| $command += " -$($parameter.Name)" | ||
| if ($parts.Length -eq 2) { | ||
| $command += " '$($parts[1].Replace("'", "''"))'" | ||
| } | ||
| } | ||
| elseif ($arg -match '^-[A-Za-z]+$') { | ||
| $command += " $arg" | ||
| } | ||
| else { | ||
| $command += " '$($arg.Replace("'", "''"))'" | ||
| } | ||
| } | ||
|
|
||
| $command += ' 6>&1; exit $LASTEXITCODE' | ||
| $encodedCommand = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($command)) | ||
| & powershell -ExecutionPolicy ByPass -NoProfile -OutputFormat Text -EncodedCommand $encodedCommand | ||
| exit $LASTEXITCODE | ||
| } | ||
| catch { | ||
| Write-Error $_ -ErrorAction Continue | ||
| exit 1 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The full solution builds successfully with
.\build.cmd -platform x64, andScratchProjectcorrectly produceswin-x64.Building an individual project fails:
System.Windows.Formsfails with CS8034 becauseSystem.Windows.Forms.PrivateSourceGeneratorsis built toartifacts\bin\...\x64\Debug\nets…dard2.0\as an x64 assembly, which the ARM64 compiler cannot load.
p:TargetArchitecture=x64without-platformworks as a workaround.