Benjamin
Benjamin

Reputation: 3826

UseSpaStaticFiles() not found after migrating to dotnet Core 3.1

After upgrading my .NetCore 2.2 application to Net Core 3.1. I am now facing issue in the startup.cs file related to a UseSpaStaticFiles() method.

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        app
            .UseCors("default")
            .UseStaticFiles()
            .UseSpaStaticFiles(); // this line is giving me error.
       .....
    }

The error says :

Error CS1061 'IApplicationBuilder' does not contain a definition for 'UseSpaStaticFiles' and no accessible extension method 'UseSpaStaticFiles' accepting a first argument of type 'IApplicationBuilder' could be found (are you missing a using directive or an assembly reference?)

To resolve the issue I have tried installing Microsoft.AspNetCore.SpaServices package from Nuget and that also didn't help.

Upvotes: 11

Views: 10216

Answers (2)

Panagiotis Kanavos
Panagiotis Kanavos

Reputation: 131364

The ASP.NET Core 2.2 to 3.0 migration guide explains that some assemblies were removed from the main ASP.NET Core package to reduce the deployment size and allow people to only include what they really need.

The section Add package references for removed assemblies. That section includes a list of the removed assemblies and the packages that need to be added back.

For SPA Services, the packages are Microsoft.AspNetCore.SpaServices and Microsoft.AspNetCore.SpaServices.Extensions

3.0 is a major version so breaking changes are expected. The Breaking Changes links to list of breaking changes by category and the detailed Github work issues

Upvotes: 6

Pablo Recalde
Pablo Recalde

Reputation: 3571

This method is contained in the

Microsoft.AspNetCore.SpaServices.Extensions

NuGet package.

Upvotes: 33

Related Questions