I cant figure out why Startup.cs is throwing this error. I tried the solutions suggested here (including restarting my machine and running dotnet restore) with no luck. Any ideas?
CS1061 'IServiceCollection' does not contain a definition for 'AddSpaStaticFiles' and no accessible extension method 'AddSpaStaticFiles' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)
using statements at the top of startup.cs:
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Myproject.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using System.Text;
//Install-Package Microsoft.AspNetCore.Session
//Install-Package AutoMapper.Extensions.Microsoft.DependencyInjection
My .csproj file contains:
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Session" Version="2.1.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.2.4" />
<PackageReference Include="Flurl.Http" Version="2.2.1" />
<PackageReference Include="jQuery" Version="3.3.1" />
<PackageReference Include="jQuery.Validation" Version="1.17.0" />
<PackageReference Include="LeanKit.API.Client" Version="1.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.2" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.1.0-preview1-final" />
</ItemGroup>
You need to install these two NuPackages:
We can see this is an extension method in the assembly of Microsoft.AspNetCore.SpaServices.Extensions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With