From 1d29d42ff797a796441c66acd36361541f10608d Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 18 Oct 2016 13:12:51 -0700 Subject: [PATCH] Remove crossgen'ed IL assemblies and then rename NI assemblies to the same as the corresponding IL images. (#2484) * Remove crossgen'ed IL assemblies and then rename NI assemblies to the same as the corresponding IL images. This is to make sure: 1. The dependency existence check by powershell.exe will pass for all TPAs. 2. CoreCLR by default will load the NI images even though it's using names of the IL images. * Update the comment to make it easy to understand --- build.psm1 | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/build.psm1 b/build.psm1 index 280b42206..df54a82e9 100644 --- a/build.psm1 +++ b/build.psm1 @@ -2437,21 +2437,24 @@ function Start-CrossGen { Generate-CrossGenAssembly -CrossgenPath $crossGenPath -AssemblyPath $assemblyPath } - <# - # The latest dotnet.exe from .NET Core 1.1.0 preview packages starts - # to check the existence of all TPA assemblies, including those built - # from local projects (e.g. powershell assemblies). The TPA assemblies - # in '.deps.json' are IL assemblies, so we cannot remove those ILs. - # - Write-Verbose "PowerShell Ngen assemblies have been generated, deleting ILs..." -Verbose + # + # 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 $psCoreAssemblyList) { # Remove the IL assembly and its symbols. $assemblyPath = Join-Path $PublishPath $assemblyName - $symbolsPath = $assemblyPath.Replace(".dll", ".pdb") - Remove-Item $assemblyPath -Force -ErrorAction SilentlyContinue - Remove-Item $symbolsPath -Force -ErrorAction SilentlyContinue + $symbolsPath = [System.IO.Path]::ChangeExtension($assemblyPath, ".pdb") + Remove-Item $assemblyPath -Force -ErrorAction Stop + Remove-Item $symbolsPath -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 } - #> } # Cleans the PowerShell repo