Skip to content

Commit 625daae

Browse files
committed
Fix
1 parent 82c0e96 commit 625daae

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

AspNetCore.SassCompiler.Tasks/CompileSass.cs

Lines changed: 8 additions & 5 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);
@@ -231,8 +231,8 @@ private IEnumerable<ITaskItem> GenerateCss(SassCompilerOptions options)
231231
var compilationsWithSources = new List<SassCompilerCompilationOptions>();
232232
foreach (var compilation in options.GetAllCompilations())
233233
{
234-
var fullSource = Path.GetFullPath(Path.Combine(rootFolder, compilation.Source));
235-
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));
236236

237237
if (!Directory.Exists(fullSource) && !File.Exists(fullSource))
238238
{
@@ -243,6 +243,8 @@ private IEnumerable<ITaskItem> GenerateCss(SassCompilerOptions options)
243243
}
244244

245245
hasSources = true;
246+
247+
// Note SassCompilerCompilationOptions nominalises DirectorySeperator to "/"
246248
compilationsWithSources.Add(new SassCompilerCompilationOptions{Source = fullSource, Target = fullTarget});
247249
processArguments.AppendFormat(" \"{0}\":\"{1}\"", fullSource, fullTarget);
248250
}
@@ -274,17 +276,18 @@ private IEnumerable<ITaskItem> GenerateCss(SassCompilerOptions options)
274276
// one to one
275277
if (File.Exists(compilationWithSource.Source))
276278
{
277-
var targetFile = compilationWithSource.Target.Replace(rootFolder + Path.DirectorySeparatorChar, string.Empty);
279+
var targetFile = compilationWithSource.Target.Replace(nominalisedRootFolder + '/', string.Empty);
278280
yield return new TaskItem(targetFile);
279281
}
280282
// many to many
281283
else
282284
{
283285
foreach(var sourceFile in Directory.GetFiles(compilationWithSource.Source, "*.scss", SearchOption.AllDirectories))
284286
{
287+
var nominalisedSourceFile = sourceFile.Replace('\\', '/');
285288
if (!Path.GetFileName(sourceFile).StartsWith("_"))
286289
{
287-
var targetFile = sourceFile.Replace(compilationWithSource.Source, compilationWithSource.Target).Replace("scss", "css").Replace(rootFolder + Path.DirectorySeparatorChar, string.Empty);
290+
var targetFile = nominalisedSourceFile.Replace(compilationWithSource.Source, compilationWithSource.Target).Replace("scss", "css").Replace(nominalisedRootFolder + '/', string.Empty);
288291
yield return new TaskItem(targetFile);
289292
}
290293
}

0 commit comments

Comments
 (0)