diff --git a/PowerShell.Common.props b/PowerShell.Common.props
index ba5e6e2df..4054cd5b1 100644
--- a/PowerShell.Common.props
+++ b/PowerShell.Common.props
@@ -138,6 +138,7 @@
net6.0
10.0
true
+ true
true
true
diff --git a/build.psm1 b/build.psm1
index 97b89b1a0..1f600cf05 100644
--- a/build.psm1
+++ b/build.psm1
@@ -314,8 +314,6 @@ function Start-PSBuild {
[ValidateSet('Debug', 'Release', 'CodeCoverage', '')] # We might need "Checked" as well
[string]$Configuration,
- [switch]$CrossGen,
-
[ValidatePattern("^v\d+\.\d+\.\d+(-\w+(\.\d{1,2})?)?$")]
[ValidateNotNullOrEmpty()]
[string]$ReleaseTag,
@@ -343,10 +341,6 @@ function Start-PSBuild {
}
if ($ForMinimalSize) {
- if ($CrossGen) {
- throw "Build for the minimal size requires the minimal disk footprint, so `CrossGen` is not allowed"
- }
-
if ($Runtime -and "linux-x64", "win7-x64", "osx-x64" -notcontains $Runtime) {
throw "Build for the minimal size is enabled only for following runtimes: 'linux-x64', 'win7-x64', 'osx-x64'"
}
@@ -414,7 +408,6 @@ Fix steps:
# set output options
$OptionsArguments = @{
- CrossGen=$CrossGen
Output=$Output
Runtime=$Runtime
Configuration=$Configuration
@@ -529,12 +522,6 @@ Fix steps:
Write-Log -message "Run dotnet $Arguments from $PWD"
Start-NativeExecution { dotnet $Arguments }
Write-Log -message "PowerShell output: $($Options.Output)"
-
- if ($CrossGen) {
- # fxdependent package cannot be CrossGen'ed
- Start-CrossGen -PublishPath $publishPath -Runtime $script:Options.Runtime
- Write-Log -message "pwsh.exe with ngen binaries is available at: $($Options.Output)"
- }
} else {
$globalToolSrcFolder = Resolve-Path (Join-Path $Options.Top "../Microsoft.PowerShell.GlobalTool.Shim") | Select-Object -ExpandProperty Path
@@ -837,8 +824,6 @@ function New-PSOptions {
"win7-x86")]
[string]$Runtime,
- [switch]$CrossGen,
-
# Accept a path to the output directory
# If not null or empty, name of the executable will be appended to
# this path, otherwise, to the default path, and then the full path
@@ -944,7 +929,6 @@ function New-PSOptions {
-RootInfo ([PSCustomObject]$RootInfo) `
-Top $Top `
-Runtime $Runtime `
- -Crossgen $Crossgen.IsPresent `
-Configuration $Configuration `
-PSModuleRestore $PSModuleRestore.IsPresent `
-Framework $Framework `
@@ -2360,211 +2344,6 @@ function script:Start-NativeExecution
}
}
-function Start-CrossGen {
- [CmdletBinding()]
- param(
- [Parameter(Mandatory= $true)]
- [ValidateNotNullOrEmpty()]
- [String]
- $PublishPath,
-
- [Parameter(Mandatory=$true)]
- [ValidateSet("alpine-x64",
- "linux-arm",
- "linux-arm64",
- "linux-x64",
- "osx-arm64",
- "osx-x64",
- "win-arm",
- "win-arm64",
- "win7-x64",
- "win7-x86")]
- [string]
- $Runtime
- )
-
- function New-CrossGenAssembly {
- param (
- [Parameter(Mandatory = $true)]
- [ValidateNotNullOrEmpty()]
- [String[]]
- $AssemblyPath,
-
- [Parameter(Mandatory = $true)]
- [ValidateNotNullOrEmpty()]
- [String]
- $CrossgenPath,
-
- [Parameter(Mandatory = $true)]
- [ValidateSet("alpine-x64",
- "linux-arm",
- "linux-arm64",
- "linux-x64",
- "osx-arm64",
- "osx-x64",
- "win-arm",
- "win-arm64",
- "win7-x64",
- "win7-x86")]
- [string]
- $Runtime
- )
-
- $platformAssembliesPath = Split-Path $AssemblyPath[0] -Parent
-
- $targetOS, $targetArch = $Runtime -split '-'
-
- # Special cases where OS / Arch does not conform with runtime names
- switch ($Runtime) {
- 'alpine-x64' {
- $targetOS = 'linux'
- $targetArch = 'x64'
- }
- 'win-arm' {
- $targetOS = 'windows'
- $targetArch = 'arm'
- }
- 'win-arm64' {
- $targetOS = 'windows'
- $targetArch = 'arm64'
- }
- 'win7-x64' {
- $targetOS = 'windows'
- $targetArch = 'x64'
- }
- 'win7-x86' {
- $targetOS = 'windows'
- $targetArch = 'x86'
- }
- }
-
- $generatePdb = $targetos -eq 'windows'
-
- # The path to folder must end with directory separator
- $dirSep = [System.IO.Path]::DirectorySeparatorChar
- $platformAssembliesPath = if (-not $platformAssembliesPath.EndsWith($dirSep)) { $platformAssembliesPath + $dirSep }
-
- Start-NativeExecution {
- $crossgen2Params = @(
- "-r"
- $platformAssembliesPath
- "--out-near-input"
- "--single-file-compilation"
- "-O"
- "--targetos"
- $targetOS
- "--targetarch"
- $targetArch
- )
-
- if ($generatePdb) {
- $crossgen2Params += "--pdb"
- }
-
- $crossgen2Params += $AssemblyPath
-
- & $CrossgenPath $crossgen2Params
- }
- }
-
- if (-not (Test-Path $PublishPath)) {
- throw "Path '$PublishPath' does not exist."
- }
-
- # Get the path to crossgen
- $crossGenExe = if ($environment.IsWindows) { "crossgen2.exe" } else { "crossgen2" }
-
- # The crossgen tool is only published for these particular runtimes
- $crossGenRuntime = if ($environment.IsWindows) {
- # for windows the tool architecture is the host machine architecture, so it is always x64.
- # we can cross compile for x86, arm and arm64
- "win-x64"
- } else {
- $Runtime
- }
-
- if (-not $crossGenRuntime) {
- throw "crossgen is not available for this platform"
- }
-
- $dotnetRuntimeVersion = $script:Options.Framework -replace 'net'
-
- # Get the CrossGen.exe for the correct runtime with the latest version
- $crossGenPath = Get-ChildItem $script:Environment.nugetPackagesRoot $crossGenExe -Recurse | `
- Where-Object { $_.FullName -match $crossGenRuntime } | `
- Where-Object { $_.FullName -match $dotnetRuntimeVersion } | `
- Where-Object { (Split-Path $_.FullName -Parent).EndsWith('tools') } | `
- Sort-Object -Property FullName -Descending | `
- Select-Object -First 1 | `
- ForEach-Object { $_.FullName }
- if (-not $crossGenPath) {
- throw "Unable to find latest version of crossgen2.exe. 'Please run Start-PSBuild -Clean' first, and then try again."
- }
- Write-Verbose "Matched CrossGen2.exe: $crossGenPath" -Verbose
-
- # Common assemblies used by Add-Type or assemblies with high JIT and no pdbs to crossgen
- $commonAssembliesForAddType = @(
- "Microsoft.CodeAnalysis.CSharp.dll"
- "Microsoft.CodeAnalysis.dll"
- "System.Linq.Expressions.dll"
- "Microsoft.CSharp.dll"
- "System.Runtime.Extensions.dll"
- "System.Linq.dll"
- "System.Collections.Concurrent.dll"
- "System.Collections.dll"
- "Newtonsoft.Json.dll"
- "System.IO.FileSystem.dll"
- "System.Diagnostics.Process.dll"
- "System.Threading.Tasks.Parallel.dll"
- "System.Security.AccessControl.dll"
- "System.Text.Encoding.CodePages.dll"
- "System.Private.Uri.dll"
- "System.Threading.dll"
- "System.Security.Principal.Windows.dll"
- "System.Console.dll"
- "Microsoft.Win32.Registry.dll"
- "System.IO.Pipes.dll"
- "System.Diagnostics.FileVersionInfo.dll"
- "System.Collections.Specialized.dll"
- "Microsoft.ApplicationInsights.dll"
- )
-
- $fullAssemblyList = $commonAssembliesForAddType
-
- $assemblyFullPaths = @()
- $assemblyFullPaths += foreach ($assemblyName in $fullAssemblyList) {
- Join-Path $PublishPath $assemblyName
- }
-
- New-CrossGenAssembly -CrossgenPath $crossGenPath -AssemblyPath $assemblyFullPaths -Runtime $Runtime
-
- #
- # With the latest dotnet.exe, the default load context is only able to load TPAs, and TPA
- # only contains IL assembly names. In order to make the default load context able to load
- # the NI PS assemblies, we need to replace the IL PS assemblies with the corresponding NI
- # PS assemblies, but with the same IL assembly names.
- #
- Write-Verbose "PowerShell Ngen assemblies have been generated. Deploying ..." -Verbose
- foreach ($assemblyName in $fullAssemblyList) {
-
- # Remove the IL assembly and its symbols.
- $assemblyPath = Join-Path $PublishPath $assemblyName
- $symbolsPath = [System.IO.Path]::ChangeExtension($assemblyPath, ".pdb")
-
- Remove-Item $assemblyPath -Force -ErrorAction Stop
-
- # Rename the corresponding ni.dll assembly to be the same as the IL assembly
- $niAssemblyPath = [System.IO.Path]::ChangeExtension($assemblyPath, "ni.dll")
- Rename-Item $niAssemblyPath $assemblyPath -Force -ErrorAction Stop
-
- # No symbols are available for Microsoft.CodeAnalysis.CSharp.dll, Microsoft.CodeAnalysis.dll,
- # Microsoft.CodeAnalysis.VisualBasic.dll, and Microsoft.CSharp.dll.
- if ($commonAssembliesForAddType -notcontains $assemblyName) {
- Remove-Item $symbolsPath -Force -ErrorAction Stop
- }
- }
-}
-
# Cleans the PowerShell repo - everything but the root folder
function Clear-PSRepo
{
@@ -3087,7 +2866,6 @@ function Restore-PSOptions {
-RootInfo $options.RootInfo `
-Top $options.Top `
-Runtime $options.Runtime `
- -Crossgen $options.Crossgen `
-Configuration $options.Configuration `
-PSModuleRestore $options.PSModuleRestore `
-Framework $options.Framework `
@@ -3111,10 +2889,6 @@ function New-PSOptionsObject
[String]
$Runtime,
- [Parameter(Mandatory)]
- [Bool]
- $CrossGen,
-
[Parameter(Mandatory)]
[String]
$Configuration,
@@ -3143,7 +2917,6 @@ function New-PSOptionsObject
Framework = $Framework
Runtime = $Runtime
Output = $Output
- CrossGen = $CrossGen
PSModuleRestore = $PSModuleRestore
ForMinimalSize = $ForMinimalSize
}
diff --git a/tools/ci.psm1 b/tools/ci.psm1
index ee181f168..432c00d62 100644
--- a/tools/ci.psm1
+++ b/tools/ci.psm1
@@ -99,7 +99,7 @@ function Invoke-CIBuild
Start-PSBuild -Configuration 'CodeCoverage' -PSModuleRestore -CI -ReleaseTag $releaseTag
}
- Start-PSBuild -CrossGen -PSModuleRestore -Configuration 'Release' -CI -ReleaseTag $releaseTag
+ Start-PSBuild -PSModuleRestore -Configuration 'Release' -CI -ReleaseTag $releaseTag
Save-PSOptions
$options = (Get-PSOptions)
@@ -470,7 +470,7 @@ function Invoke-CIFinish
$prereleaseIteration = (get-date).Day
$preReleaseVersion = "$previewPrefix-$previewLabel.$prereleaseIteration"
# Build clean before backing to remove files from testing
- Start-PSBuild -CrossGen -PSModuleRestore -Configuration 'Release' -ReleaseTag $preReleaseVersion -Clean -Runtime $Runtime -output $buildFolder -PSOptionsPath "${buildFolder}/psoptions.json"
+ Start-PSBuild -PSModuleRestore -Configuration 'Release' -ReleaseTag $preReleaseVersion -Clean -Runtime $Runtime -output $buildFolder -PSOptionsPath "${buildFolder}/psoptions.json"
$options = Get-PSOptions
# Remove symbol files.
$filter = Join-Path -Path (Split-Path $options.Output) -ChildPath '*.pdb'
@@ -481,7 +481,7 @@ function Invoke-CIFinish
$releaseTagParts = $releaseTag.split('.')
$preReleaseVersion = $releaseTagParts[0]+ ".9.9"
Write-Verbose "newPSReleaseTag: $preReleaseVersion" -Verbose
- Start-PSBuild -CrossGen -PSModuleRestore -Configuration 'Release' -ReleaseTag $preReleaseVersion -Clean -Runtime $Runtime -output $buildFolder -PSOptionsPath "${buildFolder}/psoptions.json"
+ Start-PSBuild -PSModuleRestore -Configuration 'Release' -ReleaseTag $preReleaseVersion -Clean -Runtime $Runtime -output $buildFolder -PSOptionsPath "${buildFolder}/psoptions.json"
$options = Get-PSOptions
# Remove symbol files.
$filter = Join-Path -Path (Split-Path $options.Output) -ChildPath '*.pdb'
diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1
index d7669e343..c1c04ada6 100644
--- a/tools/packaging/packaging.psm1
+++ b/tools/packaging/packaging.psm1
@@ -117,17 +117,6 @@ function Start-PSPackage {
$Script:Options = Get-PSOptions
$actualParams = @()
- $crossGenCorrect = $false
- if ($Runtime -match "arm" -or $Type -eq 'min-size') {
- ## crossgen doesn't support arm32/64;
- ## For the min-size package, we intentionally avoid crossgen.
- $crossGenCorrect = $true
- }
- elseif ($Script:Options.CrossGen) {
- $actualParams += '-CrossGen'
- $crossGenCorrect = $true
- }
-
$PSModuleRestoreCorrect = $false
# Require PSModuleRestore for packaging without symbols
@@ -144,14 +133,13 @@ function Start-PSPackage {
}
$precheckFailed = if ($Type -like 'fxdependent*' -or $Type -eq 'tar-alpine') {
- ## We do not check for runtime and crossgen for framework dependent package.
+ ## We do not check on runtime for framework dependent package.
-not $Script:Options -or ## Start-PSBuild hasn't been executed yet
-not $PSModuleRestoreCorrect -or ## Last build didn't specify '-PSModuleRestore' correctly
$Script:Options.Configuration -ne $Configuration -or ## Last build was with configuration other than 'Release'
$Script:Options.Framework -ne $script:netCoreRuntime ## Last build wasn't for CoreCLR
} else {
-not $Script:Options -or ## Start-PSBuild hasn't been executed yet
- -not $crossGenCorrect -or ## Last build didn't specify '-CrossGen' correctly
-not $PSModuleRestoreCorrect -or ## Last build didn't specify '-PSModuleRestore' correctly
$Script:Options.Runtime -ne $Runtime -or ## Last build wasn't for the required RID
$Script:Options.Configuration -ne $Configuration -or ## Last build was with configuration other than 'Release'
@@ -171,14 +159,8 @@ function Start-PSPackage {
# also ensure `Start-PSPackage` does what the user asks/expects, because once packages
# are generated, it'll be hard to verify if they were built from the correct content.
-
$params = @('-Clean')
- # CrossGen cannot be done for framework dependent package as it is runtime agnostic.
- if ($Type -notlike 'fxdependent*') {
- $params += '-CrossGen'
- }
-
if (!$IncludeSymbols.IsPresent) {
$params += '-PSModuleRestore'
}
@@ -4147,9 +4129,6 @@ function Invoke-AzDevOpsLinuxPackageBuild {
# We are cross compiling, so we can't generate experimental features
$buildParams.Add("SkipExperimentalFeatureGeneration", $true)
}
- default {
- $buildParams.Add("Crossgen", $true)
- }
}
$buildFolder = "${env:SYSTEM_ARTIFACTSDIRECTORY}/${mainLinuxBuildFolder}"
@@ -4169,7 +4148,6 @@ function Invoke-AzDevOpsLinuxPackageBuild {
Remove-Item -Path $binDir -Recurse -Force
}
- $buildParams['Crossgen'] = $false
$buildParams['ForMinimalSize'] = $true
$buildFolder = "${env:SYSTEM_ARTIFACTSDIRECTORY}/${minSizeLinuxBuildFolder}"
Start-PSBuild -Clean @buildParams @releaseTagParam -Output $buildFolder -PSOptionsPath "${buildFolder}-meta/psoptions.json"
diff --git a/tools/releaseBuild/Images/GenericLinuxFiles/PowerShellPackage.ps1 b/tools/releaseBuild/Images/GenericLinuxFiles/PowerShellPackage.ps1
index 9635bee4f..a3834fdf8 100644
--- a/tools/releaseBuild/Images/GenericLinuxFiles/PowerShellPackage.ps1
+++ b/tools/releaseBuild/Images/GenericLinuxFiles/PowerShellPackage.ps1
@@ -63,7 +63,6 @@ function BuildPackages {
} else {
# make the artifact name unique
$projectAssetsZipName = "linuxProjectAssets-$((Get-Date).Ticks)-symbols.zip"
- $buildParams.Add("Crossgen", $true)
}
Start-PSBuild @buildParams @releaseTagParam
@@ -89,7 +88,6 @@ function BuildPackages {
Remove-Item -Path $binDir -Recurse -Force
## Build 'min-size' and create 'tar.gz' package for it.
- $buildParams['Crossgen'] = $false
$buildParams['ForMinimalSize'] = $true
Start-PSBuild @buildParams @releaseTagParam
Start-PSPackage -Type min-size @releaseTagParam -LTS:$LTS
diff --git a/tools/releaseBuild/Images/microsoft_powershell_windowsservercore/PowerShellPackage.ps1 b/tools/releaseBuild/Images/microsoft_powershell_windowsservercore/PowerShellPackage.ps1
index ee8dec540..40fe755cd 100644
--- a/tools/releaseBuild/Images/microsoft_powershell_windowsservercore/PowerShellPackage.ps1
+++ b/tools/releaseBuild/Images/microsoft_powershell_windowsservercore/PowerShellPackage.ps1
@@ -97,7 +97,6 @@ try
{
Write-Verbose "Starting powershell build for RID: $Runtime and ReleaseTag: $ReleaseTag ..." -Verbose
$buildParams = @{
- CrossGen = !$ForMinimalSize -and $Runtime -notmatch "arm" -and $Runtime -notlike "fxdependent*"
ForMinimalSize = $ForMinimalSize
}
diff --git a/tools/releaseBuild/macOS/PowerShellPackageVsts.ps1 b/tools/releaseBuild/macOS/PowerShellPackageVsts.ps1
index 3b243dc71..92d64b479 100644
--- a/tools/releaseBuild/macOS/PowerShellPackageVsts.ps1
+++ b/tools/releaseBuild/macOS/PowerShellPackageVsts.ps1
@@ -104,15 +104,14 @@ try {
}
if ($Build) {
- $runCrossgen = $Runtime -eq 'osx-x64'
if ($Symbols) {
- Start-PSBuild -Clean -Configuration 'Release' -Crossgen:$runCrossgen -NoPSModuleRestore @releaseTagParam -Runtime $Runtime
+ Start-PSBuild -Clean -Configuration 'Release' -NoPSModuleRestore @releaseTagParam -Runtime $Runtime
$pspackageParams['Type']='zip'
$pspackageParams['IncludeSymbols']=$Symbols.IsPresent
Write-Verbose "Starting powershell packaging(zip)..." -Verbose
Start-PSPackage @pspackageParams @releaseTagParam
} else {
- Start-PSBuild -Configuration 'Release' -Crossgen:$runCrossgen -PSModuleRestore @releaseTagParam -Runtime $Runtime
+ Start-PSBuild -Configuration 'Release' -PSModuleRestore @releaseTagParam -Runtime $Runtime
Start-PSPackage @pspackageParams @releaseTagParam
switch ($ExtraPackage) {
"tar" { Start-PSPackage -Type tar @pspackageParams @releaseTagParam }