excubo-ag / WebCompiler

Apache License 2.0
149 stars 30 forks source link

dotnet 5 #6

Closed doyce closed 4 years ago

doyce commented 4 years ago

At first I would like to thank the author for this wonderfull tool that finally allowed me to get rid of webpack in my Blazor project :)

Now the issue I have: I tried to run the tool inside a docker container based on dotnet/sdk:5.0 image but it threw an error: The framework 'Microsoft.NETCore.App', version '3.1.0' was not found.

Would it be possible to have this tool available for dotnet 5 as well?

stefanloerwald commented 4 years ago

Hi @doyce, could you please share the line where you add WebCompiler? That could help pinpoint the issue.

doyce commented 4 years ago

I install it in the dockerfile like this: RUN dotnet tool install Excubo.WebCompiler --global --version 2.3.6

It gets installed successfully, it just cannot run because the only available framework in the container is dotnet 5.

doyce commented 4 years ago

This is the full error message:

It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '3.1.0' was not found.
  - The following frameworks were found:
      5.0.0-preview.8.20407.11 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.
stefanloerwald commented 4 years ago

I understand now, thanks for the clarification. That seems to be an issue of missing runtime. dotnet/sdk:5.0 includes multiple sdks, but only the 5.0 runtime. I will look into adaptations to this tool.

In the mean time, you can probably work around this by using docker build steps:

FROM mcr.microsoft.com/dotnet/core/sdk:5.0 AS build
COPY . .
RUN dotnet build # any build steps except webcompiler
FROM mcr.microsoft.com/dotnet/core/runtime:3.1 as webcompile
RUN dotnet tool install Excubo.WebCompiler --global --version 2.3.6 # install web compiler in a 3.1 runtime context
RUN webcompiler -r wwwroot # execute web compiler here
FROM mcr.microsoft.com/dotnet/runtime:5.0 as run # last step: assemble
COPY --from=webcompile wwwroot/compiled.min.css . # copy the results of webcompiler into the right place for execution of the container
stefanloerwald commented 4 years ago

Not much mean time I'm giving you here: seems like the change is super straight-forward. A new version (will be 2.4.0) is on its way and should now work with .net core 3.1 or .net 5.0. Please report back if this solves your issue!

doyce commented 4 years ago

It works now! Thanks for your help.