Skip to content

Microsoft.Extensions.FileProviders.Embedded Fails in .NET 10 with InvalidOperationException #63719

@PikachuCN

Description

@PikachuCN

Is there an existing issue for this?

  • 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

<PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
</PropertyGroup>

<ItemGroup>
    <EmbeddedResource Include="wwwroot\**" />
</ItemGroup>

<ItemGroup>
    <PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="10.0.0-rc.1.25451.107" />
</ItemGroup>

Use the following code in Program.cs to serve the embedded files:

C#

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:

System.InvalidOperationException: “Could not load the embedded file manifest 'Microsoft.Extensions.FileProviders.Embedded.Manifest.xml' for assembly 'NetProbe'.”
A build warning is displayed:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-embedded-fileprovider

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions