Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throws exception on request for any CSS file #1

Open
Pilchard123 opened this issue Jan 8, 2020 · 3 comments
Open

Throws exception on request for any CSS file #1

Pilchard123 opened this issue Jan 8, 2020 · 3 comments

Comments

@Pilchard123
Copy link

Pilchard123 commented Jan 8, 2020

I created a new ASP.NET Core Web Application project targeting .NET Core 3.1 in VS2019 (and here's a repro project) and made no changes other than to add Ligershark.WebOptimizer.Core v3.0.250 and Ligershark.WebOptimizer.AutoPrefixer v7.1.8-beta and the relevant code in Startup.Confugure and Startup.ConfigureServices. If services.AddWebOptimizer(pipeline => pipeline.MinifyCssFiles().AutoPrefixCss()); is used, an exception (stack trace below) is thrown on requests to /css/site.css. If services.AddWebOptimizer(pipeline => pipeline.MinifyCssFiles()); is used, no exception is thrown.

System.MissingMethodException: Method not found: 'Void Microsoft.Extensions.Logging.Console.ConsoleLogger..ctor(System.String, System.Func`3<System.String,Microsoft.Extensions.Logging.LogLevel,Boolean>, Boolean)'.
  at Microsoft.AspNetCore.NodeServices.NodeServicesOptions..ctor(IServiceProvider serviceProvider)
   at Microsoft.Extensions.DependencyInjection.NodeServicesServiceCollectionExtensions.<>c__DisplayClass1_0.<AddNodeServices>b__0(IServiceProvider serviceProvider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at WebOptimizer.NodeServices.NodeProcessor.CreateNodeServicesInstance()
   at WebOptimizer.NodeServices.NodeProcessor.get_NodeServices()
   at WebOptimizer.AutoPrefixer.AutoPrefixerProcessor.ExecuteAsync(IAssetContext context)
   at WebOptimizer.Asset.ExecuteAsync(HttpContext context, IWebOptimizerOptions options)
   at WebOptimizer.AssetBuilder.BuildAsync(IAsset asset, HttpContext context, IWebOptimizerOptions options)
   at WebOptimizer.AssetMiddleware.HandleAssetAsync(HttpContext context, IAsset asset, WebOptimizerOptions options)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
@bgege
Copy link

bgege commented Jan 13, 2020

I can confirm, exact same thing happened to me

@maxiostro
Copy link

After looking at this issue for some time, I finally came out with a solution. This package was designed for .NET Standard 2.0, not for .NET Core 3.0.
Just add <PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.1.6" /> to your Startap.cs (inside <ItemGroup>) and re build. That will update the dependencies (the only .NET external dependence, actually), and will fix the issue
@ligershark I can work in a PR to update all this to 3.0 if you want to.

@madskristensen
Copy link
Member

madskristensen commented Jul 29, 2020

@maxiostro That's a great idea. In the .csproj, let's make sure to udpate the version from 1.x to 3.0 and drop the -beta. That makes it more clear that the nuget package targets 3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants