Taritsyn / LibSassHost

.NET wrapper around the LibSass library with the ability to support a virtual file system.
Apache License 2.0
82 stars 11 forks source link

No CSS or .map files are output, despite correct output path specified #10

Closed jakelauer closed 7 years ago

jakelauer commented 7 years ago

I have set up a build step to use this library to build my SCSS files. It successfully finds all my SCSS files, and the result from the compilation shows their contents, but no files are actually output to the folder. Is there a special setting I need, or a folder permission perhaps?

Here is the code to build them:

` using System; using System.IO; using LibSassHost; using LibSassHost.Helpers;

namespace Build
{
    class SassBuild : Microsoft.Build.Utilities.Task
    {
        public static void Main()
        {
            var sassBuild = new SassBuild();
            var result = sassBuild.Execute();

            if (result)
            {
                Console.WriteLine("Sass build Completed.");
                Environment.ExitCode = 0;
            }
            else
            {
                Console.WriteLine("Sass build Failed.");
                Environment.ExitCode = 1;
            }
        }

        public override bool Execute()
        {
            var basePath = Path.GetFullPath(@"..\..\..\coherent\");

            var files = Directory.GetFiles(basePath, "*.scss", SearchOption.AllDirectories);

            using (var compiler = new SassCompiler())
            {
                try
                {
                    foreach (var file in files)
                    {
                        var options = new CompilationOptions { SourceMap = true };
                        var result = compiler.CompileFile(file, Path.ChangeExtension(file, "css"), options);

                        Console.WriteLine("Compiled content:{1}{1}{0}{1}", result.CompiledContent,
                            Environment.NewLine);
                        Console.WriteLine("Source map:{1}{1}{0}{1}", result.SourceMap, Environment.NewLine);
                        Console.WriteLine("Included file paths: {0}",
                            string.Join(", ", result.IncludedFilePaths));
                    }
                }
                catch (SassСompilationException e)
                {
                    Console.WriteLine("During compilation of SCSS file an error occurred. See details:");
                    Console.WriteLine();
                    Console.WriteLine(SassErrorHelpers.Format(e));
                }
            }

            return true;
        }
    }
}`
Taritsyn commented 7 years ago

Hello, Jake!

Have you read the documentation?

Quote from documentation:

It should also be noted, that this library does not write the result of compilation to disk. Compile and CompileFile methods of the SassCompiler class return the result of compilation in the form of an instance of the CompilationResult class.

jakelauer commented 7 years ago

The reason I posted was because it allows you to specify an outputPath, which doesn't appear to actually do anything.

Taritsyn commented 7 years ago

Quote from documentation:

outputPath (optional) - path to output CSS file. Needed for generation of source map. If path to output file is not specified, but specified a path to input file, then value of this parameter is obtained by replacing extension in the input file path by .css extension.

outputPath is not my invention. See a original libSass.

Problem is that you do not want to read the documentation.

jakelauer commented 7 years ago

I see - I did not know that this was part of the original libSass stuff. It was not clear from the documentation that the outputPath did not actually specify the location that files would be created. I now understand that the reason it is used is to identify the location of the source map.