Skip to content

Commit b90a1e6

Browse files
Remove unnecessary native dependencies from the package (PowerShell#18213)
1 parent 67a3830 commit b90a1e6

File tree

3 files changed

+72
-27
lines changed

3 files changed

+72
-27
lines changed

PowerShell.Common.props

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,11 @@
172172
<PublishReadyToRun>true</PublishReadyToRun>
173173
<PublishReadyToRunEmitSymbols>true</PublishReadyToRunEmitSymbols>
174174
<Optimize>true</Optimize>
175+
<DebugType>portable</DebugType>
175176
</PropertyGroup>
176177

177178
<!-- Define all OS, release configuration properties -->
178179
<PropertyGroup Condition=" '$(Configuration)' == 'StaticAnalysis' ">
179-
<Optimize>true</Optimize>
180-
<DebugType>full</DebugType>
181-
</PropertyGroup>
182-
183-
<!-- Define windows, release configuration properties -->
184-
<PropertyGroup Condition=" '$(Configuration)' == 'Release' And '$(IsWindows)' == 'true' ">
185180
<Optimize>true</Optimize>
186181
<!-- This is required to be full for compliance tools !-->
187182
<DebugType>full</DebugType>
@@ -193,15 +188,6 @@
193188
Debugging the issues resolves the problem
194189
-->
195190
<Optimize>false</Optimize>
196-
<DebugType>portable</DebugType>
197-
</PropertyGroup>
198-
199-
<!-- Define all OS, CodeCoverage configuration properties -->
200-
<PropertyGroup Condition=" '$(Configuration)' == 'CodeCoverage' ">
201-
<!-- This is required to be portable to Coverlet tool !-->
202-
<PublishReadyToRun Condition=" '$(Configuration)' != 'Debug' ">true</PublishReadyToRun>
203-
<PublishReadyToRunEmitSymbols>true</PublishReadyToRunEmitSymbols>
204-
<DebugType>portable</DebugType>
205191
</PropertyGroup>
206192

207193
<PropertyGroup>

assets/wix/files.wxs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,9 +2936,6 @@
29362936
<Component Id="cmpF2634E50875D4698921081E3C6B1D5DC">
29372937
<File Id="fil5A54754B01054DB590032470CE5F1EBD" KeyPath="yes" Source="$(var.ProductSourcePath)\PresentationCore.dll" />
29382938
</Component>
2939-
<Component Id="cmpBFAC308E2D8645278D61C126C0FC2C61">
2940-
<File Id="fil2954DD50127543F991A9F0A539E80FA4" KeyPath="yes" Source="$(var.ProductSourcePath)\PenImc_cor3.dll" />
2941-
</Component>
29422939
<Component Id="cmp8F0E2CF1B76B4D5185CB6A8DB9236F93">
29432940
<File Id="fil91831C8BEFBB49AE8A4FDE50300CA3E8" KeyPath="yes" Source="$(var.ProductSourcePath)\PresentationFramework-SystemXml.dll" />
29442941
</Component>
@@ -3023,9 +3020,6 @@
30233020
<Component Id="cmp930F2D2320B94F6397ECD91862AF7A90">
30243021
<File Id="fil0B2E8182CDEC485F8364AB82F5EA2D35" KeyPath="yes" Source="$(var.ProductSourcePath)\PresentationFramework.Luna.dll" />
30253022
</Component>
3026-
<Component Id="cmp5C8827EF42BE4C098EF08EBD4011DA47">
3027-
<File Id="fil15D3E880E8AD4F9A970422D79FADDBAF" KeyPath="yes" Source="$(var.ProductSourcePath)\PresentationNative_cor3.dll" />
3028-
</Component>
30293023
<Component Id="cmp6C0567CC32E4457A8F2D03C6E7F5897E">
30303024
<File Id="filB46C0C9BDA404C51ACB0F93E5ADACDE5" KeyPath="yes" Source="$(var.ProductSourcePath)\WindowsFormsIntegration.dll" />
30313025
</Component>
@@ -3089,9 +3083,6 @@
30893083
<Component Id="cmp0BD7D15E0377407FA4C43BFE89F0C12E">
30903084
<File Id="fil6EF5C2AED8674A32B0F3CCEE9CBEED71" KeyPath="yes" Source="$(var.ProductSourcePath)\System.Formats.Asn1.dll" />
30913085
</Component>
3092-
<Component Id="cmpC0FFB3F4FB30438082D2DC0F4E4BF12D">
3093-
<File Id="fil8FEEEB3B27DF40148EB85CE6AE1A420B" KeyPath="yes" Source="$(var.ProductSourcePath)\Microsoft.DiaSymReader.Native.$(var.FileArchitecture).dll" />
3094-
</Component>
30953086
<Component Id="cmpB92B70CEFC2F438386F97264FB436CDD">
30963087
<File Id="fil824D1A506096432888ABC2FDFAFABEE5" KeyPath="yes" Source="$(var.ProductSourcePath)\System.Diagnostics.EventLog.Messages.dll" />
30973088
</Component>
@@ -3153,6 +3144,9 @@
31533144
<Component Id="cmp76EB2749D0464D41AD1D2BA2C51CF4C9">
31543145
<File Id="filDC81A93ACA6045E4A22C108F59D69083" KeyPath="yes" Source="$(var.ProductSourcePath)\mscordaccore_$(var.FileArchitecture)_$(var.FileArchitecture)_7.0.22.42610.dll" />
31553146
</Component>
3147+
<Component Id="cmp6986F8B66C514347A25E03DD3096B5AE">
3148+
<File Id="fil9276D1BDBF8B4C91B90761633720A419" KeyPath="yes" Source="$(var.ProductSourcePath)\PresentationNative_cor3.dll" />
3149+
</Component>
31563150
</DirectoryRef>
31573151
</Fragment>
31583152
<Fragment>
@@ -4052,7 +4046,6 @@
40524046
<ComponentRef Id="cmp30126C60BD784974B74EA45AE9B04032" />
40534047
<ComponentRef Id="cmp9EC1507780D247E095EA92A7715B4BAC" />
40544048
<ComponentRef Id="cmpF2634E50875D4698921081E3C6B1D5DC" />
4055-
<ComponentRef Id="cmpBFAC308E2D8645278D61C126C0FC2C61" />
40564049
<ComponentRef Id="cmp8F0E2CF1B76B4D5185CB6A8DB9236F93" />
40574050
<ComponentRef Id="cmp14EA1CB2EC4E4B1DB7F7968B5B3D8E16" />
40584051
<ComponentRef Id="cmpF543DDEF59CB4ACB85CBC9A106BD853D" />
@@ -4081,7 +4074,6 @@
40814074
<ComponentRef Id="cmpDEE7C0BADEA14B9A9AFFD4C9BF4E7702" />
40824075
<ComponentRef Id="cmp10ABC7FB464B42FCA1EDEC7015AFEDCF" />
40834076
<ComponentRef Id="cmp930F2D2320B94F6397ECD91862AF7A90" />
4084-
<ComponentRef Id="cmp5C8827EF42BE4C098EF08EBD4011DA47" />
40854077
<ComponentRef Id="cmp6C0567CC32E4457A8F2D03C6E7F5897E" />
40864078
<ComponentRef Id="cmp18A181D71C894FBE96F4A3563213DC57" />
40874079
<ComponentRef Id="cmp1C666476BE6044B4B8C74450F1F32E67" />
@@ -4103,7 +4095,6 @@
41034095
<ComponentRef Id="cmpE9599A00802144DF98F5792E029C8875" />
41044096
<ComponentRef Id="cmp0989343D60B74AF082291F612F0E6FA6" />
41054097
<ComponentRef Id="cmp0BD7D15E0377407FA4C43BFE89F0C12E" />
4106-
<ComponentRef Id="cmpC0FFB3F4FB30438082D2DC0F4E4BF12D" />
41074098
<ComponentRef Id="cmpB92B70CEFC2F438386F97264FB436CDD" />
41084099
<ComponentRef Id="cmp8635213A03B04AAE8E1BFB7EA85E0DB2" />
41094100
<ComponentRef Id="cmp834F3E0C83664E92B0D115A39A8FAACB" />
@@ -4166,6 +4157,7 @@
41664157
<ComponentRef Id="cmp76EB2749D0464D41AD1D2BA2C51CF4C9" />
41674158
<ComponentRef Id="cmpF5FD2E392BD94BCD957480F128A38E10" />
41684159
<ComponentRef Id="cmp28DEAACC47FD4B04A95521A375761643" />
4160+
<ComponentRef Id="cmp6986F8B66C514347A25E03DD3096B5AE" />
41694161
</ComponentGroup>
41704162
</Fragment>
41714163
</Wix>

build.psm1

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,8 @@ Fix steps:
674674
Restore-PSPester -Destination (Join-Path $publishPath "Modules")
675675
}
676676

677+
Clear-NativeDependencies -PublishFolder $publishPath
678+
677679
if ($PSOptionsPath) {
678680
$resolvedPSOptionsPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($PSOptionsPath)
679681
$parent = Split-Path -Path $resolvedPSOptionsPath
@@ -3357,3 +3359,68 @@ function Find-AzCopy {
33573359
$azCopy = Get-Command -Name azCopy -ErrorAction Stop | Select-Object -First 1
33583360
return $azCopy.Path
33593361
}
3362+
3363+
function Clear-NativeDependencies
3364+
{
3365+
param(
3366+
[Parameter(Mandatory=$true)] [string] $PublishFolder
3367+
)
3368+
3369+
$diasymFileNamePattern = 'microsoft.diasymreader.native.{0}.dll'
3370+
3371+
switch -regex ($($script:Options.Runtime)) {
3372+
'.*-x64' {
3373+
$diasymFileName = $diasymFileNamePattern -f 'amd64'
3374+
}
3375+
'.*-x86' {
3376+
$diasymFileName = $diasymFileNamePattern -f 'x86'
3377+
}
3378+
'.*-arm' {
3379+
$diasymFileName = $diasymFileNamePattern -f 'arm'
3380+
}
3381+
'.*-arm64' {
3382+
$diasymFileName = $diasymFileNamePattern -f 'arm64'
3383+
}
3384+
'fxdependent.*' {
3385+
Write-Verbose -Message "$($script:Options.Runtime) is a fxdependent runtime, skipping diasymreader removal" -Verbose
3386+
$diasymFileName = $null
3387+
}
3388+
Default {
3389+
throw "Unknown runtime $($script:Options.Runtime)"
3390+
}
3391+
}
3392+
3393+
$filesToDeleteCore = @($diasymFileName)
3394+
3395+
$filesToDeleteWinDesktop = @('penimc_cor3.dll')
3396+
3397+
$deps = Get-Content "$PublishFolder/pwsh.deps.json" -Raw | ConvertFrom-Json -Depth 20
3398+
$targetRuntime = ".NETCoreApp,Version=v7.0/$($script:Options.Runtime)"
3399+
3400+
$runtimePackNetCore = $deps.targets.${targetRuntime}.PSObject.Properties.Name -like 'runtimepack.Microsoft.NETCore.App.Runtime*'
3401+
$runtimePackWinDesktop = $deps.targets.${targetRuntime}.PSObject.Properties.Name -like 'runtimepack.Microsoft.WindowsDesktop.App.Runtime*'
3402+
3403+
if ($runtimePackNetCore)
3404+
{
3405+
$filesToDeleteCore | ForEach-Object {
3406+
Write-Verbose "Removing $_ from pwsh.deps.json" -Verbose
3407+
$deps.targets.${targetRuntime}.${runtimePackNetCore}.native.PSObject.Properties.Remove($_)
3408+
if (Test-Path $PublishFolder/$_) {
3409+
Remove-Item -Path $PublishFolder/$_ -Force -Verbose
3410+
}
3411+
}
3412+
}
3413+
3414+
if ($runtimePackWinDesktop)
3415+
{
3416+
$filesToDeleteWinDesktop | ForEach-Object {
3417+
Write-Verbose "Removing $_ from pwsh.deps.json" -Verbose
3418+
$deps.targets.${targetRuntime}.${runtimePackWinDesktop}.native.PSObject.Properties.Remove($_)
3419+
if (Test-Path $PublishFolder/$_) {
3420+
Remove-Item -Path $PublishFolder/$_ -Force -Verbose
3421+
}
3422+
}
3423+
}
3424+
3425+
$deps | ConvertTo-Json -Depth 20 | Set-Content "$PublishFolder/pwsh.deps.json" -Force
3426+
}

0 commit comments

Comments
 (0)