WebOptimizer icon indicating copy to clipboard operation
WebOptimizer copied to clipboard

WebOptimizer for .NET 5

Open nikhilramabhadra opened this issue 3 years ago • 11 comments

Does WebOptimizer work with .NET 5?

nikhilramabhadra avatar Mar 26 '21 16:03 nikhilramabhadra

Seems to be working fine for me.

VictorioBerra avatar Apr 02 '21 16:04 VictorioBerra

Yes working here too (y)

Jalinco1 avatar Apr 27 '21 06:04 Jalinco1

I will say, I am experiencing an issue where none of my CSS loads on first-load and there is an error in the console.

VictorioBerra avatar Apr 27 '21 16:04 VictorioBerra

I will say, I am experiencing an issue where none of my CSS loads on first-load and there is an error in the console.

What error you get?

in startup.cs "configure" I have: app.UseWebOptimizer(); app.UseStaticFiles();

and in "configureservices" I have: services.AddWebOptimizer(pipeline => { pipeline.AddCssBundle("/css/bundle.css", "lib/bootstrap/dist/css/bootstrap.css", "css/animate.css", "css/site.css"); pipeline.AddJavaScriptBundle("/js/bundle.js", "lib/jquery/dist/jquery.js", "/lib/bootstrap/dist/js/bootstrap.bundle.js"); });

and then use in view:

<link rel="stylesheet" href="/css/bundle.css" />

and

/T

Jalinco1 avatar Apr 27 '21 16:04 Jalinco1

@Jalinco1 This is the issue I am having, I commented here as well. https://github.com/ligershark/WebOptimizer/issues/55

VictorioBerra avatar Apr 27 '21 18:04 VictorioBerra

I am having issues with it when I try to make a pipeline in azure devops.

##[error]The nuget command failed with exit code(1) and error(NU1202: Package LigerShark.WebOptimizer.Sass 3.0.58-beta is not compatible with net50 (.NETFramework,Version=v5.0). Package LigerShark.WebOptimizer.Sass 3.0.58-beta supports: netcoreapp3.0 (.NETCoreApp,Version=v3.0)

That's from the nuGet Restore step in my pipeline. I can build it without any issues locally so it is perfectly possible that I just don't know what I'm doing.

casualinnovations avatar May 10 '21 20:05 casualinnovations

@casualinnovations Is your azure build agent building using the .net3.0 SDK?

VictorioBerra avatar May 11 '21 14:05 VictorioBerra

@casualinnovations Is your azure build agent building using the .net3.0 SDK?

It is failing during the NuGet Restore step, before building. YAML for Nuget Restore.

steps:
- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: '$(Parameters.solution)'
    vstsFeed: '971cc896-394f-4815-b290-e9d5c1b95ff6'

My project is configured for 5.0

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <CopyRefAssembliesToPublishDirectory>false</CopyRefAssembliesToPublishDirectory>
    <AssemblyName>CasualFrontend</AssemblyName>
  </PropertyGroup>

casualinnovations avatar May 11 '21 19:05 casualinnovations

Try using the dotnet cli restore cmd instead of NuGetCommand@2

VictorioBerra avatar May 11 '21 22:05 VictorioBerra

Having the same issues. afew notes:

  • deploying on a linux azure app service
  • .net 6
  • occurs usually after deployment, hit the css or js url directly and get a server 500 error, this would go away after afew hits

I have disabled disk caching from appsettings.json and the issue no longer appears to occur - obviously this carries memory penalties and startup / cold start penalties... but works for me

"webOptimizer": { "enableCaching": true, "enableMemoryCache": true, "enableDiskCache": false, "cacheDirectory": "/var/temp/weboptimizercache", "enableTagHelperBundling": false, "cdnUrl": "https://my-cdn.com/", "allowEmptyBundle": false },

my conclusion is that certain environments require cache directory path (which would be dependent on deployed environment / operating system) to be setup correctly, or disk cache to be disabled....

matthew-yee avatar Nov 20 '21 00:11 matthew-yee

@matthew-yee

my conclusion is that certain environments require cache directory path (which would be dependent on deployed environment / operating system) to be setup correctly, or disk cache to be disabled....

This is correct.

We should PR enableDiskCache set to false by default thereby making it opt-in instead of opt-out. We can update the docs to call this out, and update the samples to comment it out and describe how it works.

It clearly breaks in enough situations while on, compared to no problems if its turned off.

VictorioBerra avatar Nov 20 '21 16:11 VictorioBerra