[release/10.0] Exclude Microsoft.Extensions.FileProviders.Embedded
from pruning
#63939
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #63898 to release/10.0
/cc @MackinnonBuck
Exclude
Microsoft.Extensions.FileProviders.Embedded
from pruningExclude
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, andManifestEmbeddedFileProvider
throws anInvalidOperationException
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 unhandledInvalidOperationException
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:Without the fix, customers face broken upgrades or must disable pruning completely (not recommended).
Regression?
Worked in .NET 9 and earlier; regressed only in .NET 10
Risk
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: 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?