Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.

Commit df3aef1

Browse files
committed
Build: Always Output GeneratedFiles TaskItem
1 parent 2480d12 commit df3aef1

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

AspNetCore.SassCompiler.Tasks/CompileSass.cs

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ private static void BindCompilation(SassCompilerCompilationOptions options, IDic
213213

214214
private IEnumerable<ITaskItem> GenerateCss(SassCompilerOptions options)
215215
{
216-
var rootFolder = Directory.GetCurrentDirectory();
216+
var nominalisedRootFolder = Directory.GetCurrentDirectory().Replace('\\', '/');
217217

218218
var processArguments = new StringBuilder();
219219
processArguments.Append(Snapshot);
@@ -228,10 +228,11 @@ private IEnumerable<ITaskItem> GenerateCss(SassCompilerOptions options)
228228
}
229229

230230
var hasSources = false;
231+
var compilationsWithSources = new List<SassCompilerCompilationOptions>();
231232
foreach (var compilation in options.GetAllCompilations())
232233
{
233-
var fullSource = Path.GetFullPath(Path.Combine(rootFolder, compilation.Source));
234-
var fullTarget = Path.GetFullPath(Path.Combine(rootFolder, compilation.Target));
234+
var fullSource = Path.GetFullPath(Path.Combine(nominalisedRootFolder, compilation.Source));
235+
var fullTarget = Path.GetFullPath(Path.Combine(nominalisedRootFolder, compilation.Target));
235236

236237
if (!Directory.Exists(fullSource) && !File.Exists(fullSource))
237238
{
@@ -242,6 +243,9 @@ private IEnumerable<ITaskItem> GenerateCss(SassCompilerOptions options)
242243
}
243244

244245
hasSources = true;
246+
247+
// Note SassCompilerCompilationOptions nominalises DirectorySeperator to "/"
248+
compilationsWithSources.Add(new SassCompilerCompilationOptions{Source = fullSource, Target = fullTarget});
245249
processArguments.AppendFormat(" \"{0}\":\"{1}\"", fullSource, fullTarget);
246250
}
247251

@@ -265,24 +269,34 @@ private IEnumerable<ITaskItem> GenerateCss(SassCompilerOptions options)
265269
Log.LogWarning(error);
266270
}
267271

268-
var matches = _compiledFilesRe.Matches(output);
269-
270-
foreach (Match match in matches)
272+
// For successful dart-sass compilation we can assume the target files are in place
273+
// Always output the Content Items
274+
foreach( var compilationWithSource in compilationsWithSources)
271275
{
272-
var cssFile = match.Groups[2].Value;
273-
274-
var generatedFile = new TaskItem(cssFile);
275-
yield return generatedFile;
276+
// one to one
277+
if (File.Exists(compilationWithSource.Source))
278+
{
279+
var targetFile = compilationWithSource.Target.Replace(nominalisedRootFolder + '/', string.Empty);
280+
yield return new TaskItem(targetFile.Replace('/', '\\'));
281+
}
282+
// many to many
283+
else
284+
{
285+
foreach(var sourceFile in Directory.GetFiles(compilationWithSource.Source, "*.scss", SearchOption.AllDirectories))
286+
{
287+
var nominalisedSourceFile = sourceFile.Replace('\\', '/');
288+
if (!Path.GetFileName(sourceFile).StartsWith("_"))
289+
{
290+
var targetFile = nominalisedSourceFile.Replace(compilationWithSource.Source, compilationWithSource.Target).Replace("scss", "css").Replace(nominalisedRootFolder + '/', string.Empty);
291+
yield return new TaskItem(targetFile.Replace('/', '\\'));
292+
}
293+
}
294+
}
276295
}
277296
}
278297

279298
private (bool Success, string Output, string Error) GenerateCss(string arguments)
280299
{
281-
if (string.IsNullOrWhiteSpace(TargetFrameworks))
282-
{
283-
return CompileCss(arguments);
284-
}
285-
286300
var mutexName = GetMutexName();
287301

288302
Log.LogMessage(MessageImportance.Normal,

AspNetCore.SassCompiler/AspNetCore.SassCompiler.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>net6.0</TargetFramework>
55
<PackageId>MudBlazor.SassCompiler</PackageId>
6-
<Version>2.0.5</Version>
6+
<Version>2.0.7</Version>
77
<Authors>koenvzeijl,sleeuwen,Michaelvs97</Authors>
88
<Description>Sass Compiler Library for .NET 6 and above. without node</Description>
99
<PackageDescription>Sass Compiler Library for .NET 6 and above. without node, using dart-sass as a compiler</PackageDescription>

0 commit comments

Comments
 (0)