Skip to content

Filter Install-PSResource library assets by TFM - #2073

Draft
Justin Chung (jshigetomi) wants to merge 1 commit into
PowerShell:masterfrom
jshigetomi:jshigetomi-tfm-library-asset-filtering
Draft

Justin Chung (jshigetomi) wants to merge 1 commit into
PowerShell:masterfrom
jshigetomi:jshigetomi-tfm-library-asset-filtering

Conversation

@jshigetomi

Copy link
Copy Markdown
Contributor

PR Summary

This is the TFM-only extraction from #1963 after the combined RID/TFM implementation was reverted by #2070. It adds -TargetFramework and automatic host-framework selection to Install-PSResource without restoring any RID filtering, RuntimeIdentifier helpers, or -RuntimeIdentifier surface.

Library filtering now operates per relative asset path rather than choosing one entire lib/{tfm} directory. When the same asset exists under multiple compatible target frameworks, NuGet's framework reducer selects the nearest compatible variant for the current or explicitly requested target. Unique compatible assets remain installed even when they are spread across multiple TFM folders. This preserves the Az.Accounts shape called out in #2070 (lib/net45, lib/net47, and lib/netstandard2.0) while still removing redundant variants.

An explicit -TargetFramework can also add assets to an already-installed copy of the same version. Merge state is scoped to each parent install work item, and the merge only adds missing files without overwriting existing content. -Reinstall retains full replacement behavior.

TFM-specific dependency-group refinement is intentionally deferred in this draft. Dependency parsing remains unchanged, so an explicit target does not silently cause dependency groups to be selected using the current host framework. The empty dependencyGroups behavior fixed after the revert is not reintroduced.

Validation:

  • Passed: pwsh -NoLogo -NoProfile -File .\build.ps1 -Build with .NET SDK 10.0.402 on PATH.
  • Passed: direct dotnet publish .\src\code\Microsoft.PowerShell.PSResourceGet.csproj --configuration Debug --framework net472 --no-restore --verbosity minimal.
  • Passed on PowerShell 7.6.9: Invoke-Pester -Script .\test\InstallPSResourceTests\InstallPSResourceTargetFramework.Tests.ps1 (8 passed, 0 failed).
  • Passed on Windows PowerShell 5.1: Invoke-Pester -Script .\test\InstallPSResourceTests\InstallPSResourceTargetFramework.Tests.ps1 (8 passed, 0 failed).
  • Passed: Invoke-ScriptAnalyzer -Path .\test\InstallPSResourceTests\InstallPSResourceTargetFramework.Tests.ps1 -Severity Warning,Error (0 findings).

PR Context

The original platform-aware install work combined RID and TFM behavior. This standalone draft limits the change to TFM-aware lib/ asset selection and adds a regression fixture shaped like the Az.Accounts package layout that caused #1963 to be reverted. RID filtering is being handled separately.

PR Checklist

Select the nearest compatible variant per relative lib asset while preserving unique compatible assets across framework folders. Add explicit target merging and focused cross-edition regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant