johan-v-r / LibSassBuilder

Sass builder for .NET projects
MIT License
99 stars 14 forks source link

Msbuild retry #12

Closed JelleHissink closed 3 years ago

JelleHissink commented 3 years ago

Retry of PR: 8

Now based on the new files option

johan-v-r commented 3 years ago

Something's not working properly, or my understanding could be wrong...

Below my test findings with dotnet watch build

Watch

.scss files aren't watched by default, I still had to explicitly add <Watch Include="**\*.scss" Exclude="**\*.css" />

Files

After assigning the watch and logging (<LibSassOutputLevel>verbose</LibSassOutputLevel>) - then editing one of the .scss files, it seems to process all the .scss files:

watch : Waiting for a file to change before restarting dotnet...
watch : Started
Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  Sass compile files
  Processing: C:\SourceCode\LibSassBuilderNugetTester\LibSassBuilderNugetTester\Pages\Counter.razor.scss
  Processing: C:\SourceCode\LibSassBuilderNugetTester\LibSassBuilderNugetTester\Shared\MainLayout.razor.scss
  Processing: C:\SourceCode\LibSassBuilderNugetTester\LibSassBuilderNugetTester\wwwroot\foo.scss
  Sass files compiled

My understanding was that MSBuild would now only send changed files to LSB

JelleHissink commented 3 years ago

Watch

If you specify a LibSassBuilderArgs SassFiles are ignored (https://github.com/johan-v-r/LibSassBuilder/pull/12/files#diff-540629219a4a03215aa6df95d26b5d60f458b7f9e4737b3bfa5c826716965046R18 LibSassBuilder.targets line 18). Because SassFile items are not used at all when you specify args. Would you still want to work in that case?

Files

It does not only send changed files, I did not know what files are included, referenced or used by what other files. But it would be a nice future addition. But then we would need a list of dependencies or rules (e.g. files starting with _ => trigger all?) Also for now there is not a hash per file, but one hash over the filelisting/modification date.

In short for now: scss changes are detected the tool is run, otherwise not.

johan-v-r commented 3 years ago

Watch

Nope that test was without specifying LibSassBuilderArgs - using just the default config with a local build from your branch, see my .csproj:

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="LibSassBuilder" Version="1.5.1" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.0" PrivateAssets="all" />
    <PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
  </ItemGroup>

  <PropertyGroup>
    <LibSassOutputLevel>verbose</LibSassOutputLevel>
  </PropertyGroup>

</Project>

Files

So what's the difference/benefit of having MSBuild traversing the directory to find the files, vs letting LSB do that by default..?

JelleHissink commented 3 years ago

Watch

I'll look into it, did not test after latest refactoring

Files

JelleHissink commented 3 years ago

For me dotnet watch now works again, had to move the property to the .props file for it to work? Strange... but ok I guess