excubo-ag / WebCompiler

Apache License 2.0
149 stars 30 forks source link

Compile on file change or on save #2

Closed rwasef1830 closed 4 years ago

rwasef1830 commented 4 years ago

Hello, Is there a way to run automatically on scss file save or have it watch file changes ?

rwasef1830 commented 4 years ago

I was able to make it work:

Editing csproj:

<ItemGroup>
    <Watch Include="**\*.scss" />
</ItemGroup>

Then run from the console in the project folder:

dotnet watch tool run webcompiler -c webcompilerconfiguration.json -r wwwroot

Perhaps documentation should cite such example.

stefanloerwald commented 4 years ago

Hi @rwasef1830,

this is a valuable thing to add to the documentation. Thanks a lot for working out how to do it.

BR Stefan

softlion commented 4 years ago

Is it possible to have the same behavior as in mad christensen's version ? Ie: compiles on save without having to use a dotnet watch command line in another window.

Maybe by implementing an additional "nuget local tool" that you add to the project, like analyzers do. From mad christensen's version:

A NuGet package will be installed into the packages folder without adding any files to the project itself. The NuGet package contains an MSBuild task that will run the exact same compilers on the compilerconfig.json file in the root of the project.

Also are you on discord's dotnetevolution ?

stefanloerwald commented 4 years ago

Hi @softlion,

There's no plan to implement such a version, as it's significant effort for not much benefit. Have a look at https://github.com/excubo-ag/WebCompiler#msbuild. This shows you how to effectively get the same behavior.

Hope this helps Stefan

KKacer commented 3 years ago

I think I have a problem in enabling the watch or the command tool definition.

I get this error: Could not find a MSBuild project file in 'D:\HIH'. Specify which project to use with the --project option.

I tried the given syntax as well as the below code: (tried both)

dotnet watch tool run webcompiler -c webcompilerconfiguration.json -r wwwroot --project HIH\HIH.csproj

Did I miss anything?

@stefanloerwald @rwasef1830

rwasef1830 commented 3 years ago

I always run it from the project folder, never tried --project switch before.

stefanloerwald commented 3 years ago

This is an issue with how dotnet tool works and unrelated to webcompiler.

KKacer commented 3 years ago

@stefanloerwald fine, I fixed that, By the way, what about this issue:

https://postimg.cc/18CZxg4q

Earlier I enabled webcompiler globally, and had no issues. Should I create the tool manifest for any project, in its project directory?

stefanloerwald commented 3 years ago

Sorry but again, this is an issue with how dotnet tool works and I can't offer any help on that. It's not in scope for this project.