excubo-ag / WebCompiler

Apache License 2.0
148 stars 29 forks source link

Docker build #79

Closed KlishevichIlya closed 9 months ago

KlishevichIlya commented 9 months ago

I read your docs and as I understood I don't need to make any additional steps to run webcompiler in docker build process. I added the following code to make MS Build in my .csproj file:

<Target Name="TestWebCompiler">
    <!-- Test if Excubo.WebCompiler is installed (recommended) -->
    <Exec Command="webcompiler -h" ContinueOnError="true" StandardOutputImportance="low" StandardErrorImportance="low" LogStandardErrorAsError="false" IgnoreExitCode="true">
      <Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
    </Exec>
  </Target>

  <Target Name="CompileStaticAssets" AfterTargets="CoreCompile;TestWebCompiler" Condition="'$(ErrorCode)' == '0'">
    <Exec Command="webcompiler -r scss -c webcompilerconfiguration.json" StandardOutputImportance="high" StandardErrorImportance="high" />
  </Target>

I thought that I have dependency in my .net core app and during restore process webcompiler pack will downloaded. Unfortunately, I noticed that during docker build process there aren't any .css files in wwwroot/styles directory. Also I tried removing conditional but it didn't have any effect. How should I integrate webcompiler into docker build proccess?

stefanloerwald commented 9 months ago

For usage of this tool within a docker build process, you have to add both the command to install (RUN dotnet tool install Excubo.WebCompiler --global) and the command to run (e.g. webcompiler -r wwwroot).

You seem to be following the instructions for MSBuild integration which is different to using docker.