ligershark/WebOptimizer.Sass

After migrating from ASP.NET Core 2.0 to 2.1, libsass.dll is no longer copied to output folder on build

Opened this issue · 0 comments

I have an ASP.NET Core 2.0 web app (running on .NET Framework 4.6.1) using WebOptimizer.Sass, and after updating the project to ASP.NET Core 2.1 it would no longer drop libsass.dll in the output folder on build, and because of that I got runtime errors when a browser tried to access a CSS file that's supposed to be generated from SCSS. I tried updating to .NET Framework 4.7.2, but saw no change.

Brief stack trace:

System.DllNotFoundException: Unable to load DLL 'libsass': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at SharpScss.LibSass.sass_alloc_memory(size_t size)
   at SharpScss.LibSass.StringUtf8.op_Implicit(String text)
   at SharpScss.Scss.FromCore(String fromStringOrFile, Boolean fromFile, ScssOptions options)
   at WebOptimizer.Sass.Compiler.ExecuteAsync(IAssetContext context)
   at WebOptimizer.Asset.<ExecuteAsync>d__22.MoveNext()

As a workaround, if I install the SharpScss package directly on the project via NuGet (instead of leaving it as a nested dependency under WebOptimizer.Sass), then libsass.dll is indeed dropped in the output folder. (Though when building for AnyCPU, with the csproj not specifying a PlatformTarget, it would drop the 64-bit libsass.dll while the project would be built for x86, so I did have to update the project settings to explicitly target x64.)

I'm fine with that workaround for the time being, but I figured you might want to know about this issue since ASP.NET Core 2.1 is an LTS version, and also this way the workaround is documented/findable for others who need it.