Microsoft.Extensions.FileProviders.Embedded Fails in .NET 10 with InvalidOperationException
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
When migrating a project that uses Microsoft.Extensions.FileProviders.Embedded from .NET 8 to .NET 10, the application fails at runtime with a System.InvalidOperationException. The build process also generates a warning suggesting the package may no longer be necessary.
This functionality worked correctly in .NET 8 but is broken after upgrading to the .NET 10 RC.
### Expected Behavior
The application should start and serve the files embedded from the wwwroot directory, just as it did in .NET 8.
### Steps To Reproduce
Create a new ASP.NET Core Web Application targeting .NET 10.
Modify the .csproj file to include the following settings to embed the wwwroot folder:
```xml
net10.0
enable
enable
true
```
Use the following code in Program.cs to serve the embedded files:
```csharp
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.UseFileServer(new FileServerOptions
{
RequestPath = "",
FileProvider = new Microsoft.Extensions.FileProviders.ManifestEmbeddedFileProvider(
typeof(Program).Assembly, "wwwroot"
)
});
app.Run();
```
The application fails to start with the following runtime exception:
```text
System.InvalidOperationException: “Could not load the embedded file manifest 'Microsoft.Extensions.FileProviders.Embedded.Manifest.xml' for assembly 'NetProbe'.”
```
A build warning is displayed:
```text
PackageReference 'Microsoft.Extensions.FileProviders.Embedded' will not be removed. Consider removing this package from your dependencies as it may not be needed.
```
### Exceptions (if any)
_No response_
### .NET Version
10.0.100-rc.1.25451.107
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.