Skip to content

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Oct 6, 2025

Backport of #63898 to release/10.0

/cc @MackinnonBuck

Exclude Microsoft.Extensions.FileProviders.Embedded from pruning

Exclude Microsoft.Extensions.FileProviders.Embedded from pruning to prevent startup exceptions.

Description

In .NET 10, package reference pruning removes references to Microsoft.Extensions.FileProviders.Embedded. Unlike a runtime-only dependency, this package contributes build logic (targets/props) that generates the embedded files manifest (Microsoft.Extensions.FileProviders.Embedded.Manifest.xml). When the package reference is pruned, the manifest is never produced, and ManifestEmbeddedFileProvider throws an InvalidOperationException at startup.

The change explicitly excludes this package from pruning, so its build targets always run. Conflict resolution logic still suppresses the package's assemblies from the build output, so runtime contents remain unchanged. This restores the .NET 9 behavior.

Works around #63719

Customer Impact

Projects that successfully utilized ManifestEmbeddedFileProvider in .NET 9 fail after upgrading to .NET 10 with an unhandled InvalidOperationException on app start. A build warning incorrectly implies the package reference is unnecessary, encouraging removal and deepening confusion. To work around this issue, customers need to include the following MSBuild in all affected projects:

<Target Name="_PreserveFileProvidersEmbeddedPackageReference" AfterTargets="AddPrunePackageReferences">
  <ItemGroup>
    <PrunePackageReference Remove="Microsoft.Extensions.FileProviders.Embedded" />
  </ItemGroup>
</Target>

Without the fix, customers face broken upgrades or must disable pruning completely (not recommended).

Regression?

  • Yes
  • No

Worked in .NET 9 and earlier; regressed only in .NET 10

Risk

  • High
  • Medium
  • Low

Justification: Change only adjusts pruning exclusion; no API or runtime code paths are modified. Conflict resolution logic still prevents the package's assemblies from being copied redundantly. Effectively reverts to .NET 9 behavior.

Verification

  • Manual (required)
  • Automated

Manual: The repro project was rebuilt on a .NET 10 nightly build with the change; the manifest was generated, and the app serves embedded files successfully.

Packaging changes reviewed?

  • Yes
  • No
  • N/A

@MackinnonBuck MackinnonBuck added Servicing-consider Shiproom approval is required for the issue Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Oct 6, 2025
@wtgodbe wtgodbe merged commit 390528c into release/10.0 Oct 6, 2025
28 checks passed
@wtgodbe wtgodbe deleted the backport/pr-63898-to-release/10.0 branch October 6, 2025 18:43
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0.0 milestone Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants