Giter VIP home page Giter VIP logo

libsasshost's People

Contributors

asvishnyakov avatar hermankan avatar taritsyn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

libsasshost's Issues

Support for Memory<char> as parameter and result CSS

SCSS and CSS string could be huge some times >200KB, using Memory<char> and MemoryPool<char> could reduce allocation on LOH and improve performance.

Allowing user to pass Memory<char> as parameter and result could help in some scenario.

How to @import partials

if my SCSC contains

@import 'partials/mypartial

then a filed called partials/_mypartial.scss isn't searched for, it searches for partials/mypartial verbatim. is this expected, do I need a pimped out IFileManger to add this functionality?

Am I missing something/doing something wrong?

ta

Calling from Powershell, cannot load dependent assemblies

In Powershell, v5

Add-Type SassLibHost.dll
and then
New-Object -typeName LibSassHost.SassCompiler

This fails as follows:

New-Object : Exception calling ".ctor" with "0" argument(s): "Failed to load the LibSassHost.Native- assembly, because the directory 'C:\Windows\System32\WindowsPowerShell\v1.0\LibSassHost.Native' does not exist."

I've copied the three dlls into my current directory. Apparently, LibSassHost is searching the load directory of the current application (Powershell) instead of the current directory.

Is there any solution for this?

Also, FYI, running in Powershell 7 fails earlier with the following message. Ps7 is .net core, and LibSassHost is attempting to access a system method that does not exist in core.

System.TypeInitializationException: The type initializer for 'LibSassHost.SassCompiler' threw an exception.
---> System.MissingMethodException: Method not found: 'System.String System.AppDomainSetup.get_PrivateBinPath()'.
at LibSassHost.AssemblyResolver.GetBinDirectoryPath(AppDomain currentDomain)
at LibSassHost.AssemblyResolver.Initialize()
at LibSassHost.SassCompiler..cctor()

"Unable to load DLL 'libsass': The specified module could not be found." on windows server 2016

I have the following error after deploying to a 64 bit Windows 2016 server:

System.TypeInitializationException: The type initializer for 'LibSassHost.SassCompiler' threw an exception. ---> LibSassHost.SassCompilerLoadException: During loading of Sass-compiler error has occurred.

Most likely it happened, because failed to load the native implementation of the LibSass library. Therefore, you need to choose and install the most appropriate NuGet package(s) for your platform. The following packages are available:

* LibSassHost.Native.win-x86
* LibSassHost.Native.win-x64
* LibSassHost.Native.debian-x64
* LibSassHost.Native.osx-x64 ---> System.DllNotFoundException: Unable to load DLL 'libsass': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at LibSassHost.Internal.Native.Sass_Api.libsass_version()
   at LibSassHost.Internal.SassCompilerProxy.GetVersion()
   at LibSassHost.SassCompiler..cctor()
   --- End of inner exception stack trace ---
   at LibSassHost.SassCompiler..cctor()
   --- End of inner exception stack trace ---
   at LibSassHost.SassCompiler.Compile(String content, CompilationOptions options)

In my solution, I have referenced the following nuget packages:

  • LibSassHost
  • LibSassHost.Native.win-x64

The "msvcp140.dll" is available in the System32 folder.

NO CSS file created in OutputPath

Hello @Taritsyn ,

When I try to run the samples from https://github.com/Taritsyn/LibSassHost/tree/master/samples which is calling functions LibSassHost.SassCompiler.CompileFile() or LibSassHost.SassCompiler.Compile(), I can see the compiled string in CompilationResult but NO CSS file generated in the targeted output file path.

Do I need to install any special package to make this work?

Note: My target framework is NET40

File.WriteAllText(context.OutputPath, context.OutputString); - will this be enough to save CSS as a file?

Can you help me to resolve this issue?

Please specify a license

Please specify a license so other open source projects know what they can use it for. I am looking at possibly using this but it would need to be under MIT license

Multiple file managers

I have two separate subsystems in which I use this library to compile Sass. The subsystems are completely disjoint and require different file managers. Since the SassCompiler is now static, how can I support this use case?

System.AccessViolationException When Global Variable for a Path is Missing

I found an issue when compiling from a content string and global variable for a path is not declared.

Here is the invalid scrubbed input string:

$color-primary :#339999;
$color-secondary :#000000;
@import "C:\Source Code\svn\DEV\Web\css\scss\styles.scss"

Here is the valid scrubbed input string:

$color-primary :#339999;
$color-secondary :#000000;
$logo-path :'http://localhost/Images/image.jpg';
@import "C:\Source Code\svn\DEV\Web\css\scss\styles.scss"

Here is the code used to execute the string:

using (SassCompiler compiler = new SassCompiler())
{
    CompilationOptions options = new CompilationOptions
    {
        IncludePaths = new List<string> {scssSourceDirectory},
        OutputStyle = OutputStyle.Compressed
    };

    CompilationResult results = compiler.Compile(content, null, null, options);
    css = results.CompiledContent;
}

Here is the exception:

System.AccessViolationException was caught
  HResult=-2147467261
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=LibSassHost.Native-Proxy
  StackTrace:
       at LibSassHost.Native.Helpers.MarshallingHelper.custom_strdup(SByte* value)
       at LibSassHost.Native.Helpers.MarshallingHelper.UnmarshalConstString(SByte* value)
       at LibSassHost.Native.SassNativeCompiler.FillManagedContextError(SassContext context, Sass_Context* ctx)
       at LibSassHost.Native.SassNativeCompiler.Compile(SassDataContext dataContext)
       at LibSassHost.SassCompiler.Compile(String content, String inputPath, String outputPath, CompilationOptions options)...

Release libsass.dll after using

Hi
Is there any way to release libsass.dll after compiling sass file?

I'm using very basic implementation at BundleConfig.cs:

CompilationResult sass_result = SassCompiler.CompileFile(State.Server.MapPath("~ /Content/test.scss"));          
System.IO.File.WriteAllText(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/test.css"), sass_result.CompiledContent);

After launching site, IIS always locks libsass.dll (LibSassHost.Native.win-x86) until I stop worker process.
I didn't notice any 'Release' method to resolve this issue, assigning "null" to sass_result does not helps.
How I can avoid this?
Thank you!

File lock on LibSassHost.Native-64.dll

Hi,

I use a build server (team city) to deploy my code. When the build is finished the files are deployed with robocopy. When the files are deployed I always have a file lock on LibSassHost.Native-64.dll and I have to stop/restart the IIS to be able to deploy the files. Could it be that there is a leak the locks this file?

Here is the error from Robocopy:

Newer 1.2 m LibSassHost.Native-64.dll [17:12:28][Step 8/11] 2016/10/25 17:12:28 ERROR 32 (0x00000020) Copying File <somepath>\bin\LibSassHost.Native\LibSassHost.Native-64.dll [17:12:28][Step 8/11] The process cannot access the file because it is being used by another process. [17:12:30][Step 8/11] Waiting 2 seconds... Retrying...

Unable to load DLL 'libsass' on Windows Server 2008 R2

When using version 1.2.10, I get the following exception, though it is expected to have MSVC runtime embedded into native assemblies:

Unable to load DLL 'libsass': Exception from HRESULT: 0xC000001D
   at LibSassHost.Internal.Native.Sass_Api.libsass_version()
   at LibSassHost.SassCompiler.Initialize()
   at LibSassHost.SassCompiler.Initialize()

Just in case, there are both x64 and x86 subfolders with the native libraries within, so whether it is a 32-bit or 64-bit environment should not be an issue. I tried installing the runtime explicitly but to no avail.

I am not sure if libsass calls Windows 8 API that is not supported by Windows Server 2008 R2, which could cause the exception. Anyway I finally got it working by replacing those libraries with the ones from the libsass repository. The DLLs differ greatly in size, which makes me think of some incompleteness of LibSassHost.Native packages.

EDIT: Only Version and LanguageVersion worked but not Compile(). I recompiled libsass with MFC being a static library and that did the trick.

Combining a string of sass with an scss file

Hello, i'm not sure if this is a feature request or something that is already possible.
From what I can tell LibSassHost's SassCompiler has two methods of compiling sass.
Either a) through passing a string to .Compile(), or b) passing the path to an scss file to the .CompileFile() method.

In my use case I have an scss file as part of my project that contains all of the 'default' stylings, and in my db I have stored some values that i would like to be used to override the !defaults of the scss file at the time of compiling the scss.

I thought one of the .Compile() overloads allowed this as there is one that takes both a string content AND a string inputPath, but this didn't seem to combine the two and instead only gives me back a compiled version of the string content.

I don't see an obvious way for me to combine my string of sass variables with the file i want them to be used on. My current workaround loads up the default.scss stylesheet, reads it content, then saves a new file to disk that's got the string variables concatenated with the file contents. This isn't really ideal as reading writing and deleting the files on top of the compilation is a lot of extra overhead.

Is there some way i can combine the two without needing to do this?

Deployment Issue: Could not load file or assembly 'LibSassHost.Native-64.dll' or one of its dependencies.

Hi @Taritsyn,

I am using Bundle Transformer with the SassAndScssTranslator from NuGet. When I run the project locally, it works fine and I have no issues (scss are compiled to css and sent to client). However, when I try to deploy this to a server (no debug mode), I get the error below. Any ideas?

Server Error in '/' Application.

Could not load file or assembly 'LibSassHost.Native-64.dll' or one of its dependencies. The specified module could not be found.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'LibSassHost.Native-64.dll' or one of its dependencies. The specified module could not be found.

Source Error:

Line 11: <title data-ng-bind="pageTitle()">My Site</title>
Line 12: @Styles.Render("/bundles/bootstrapStyles")
Line 13: @Styles.Render("
/bundles/appStyles")

Source File: D:\inetpub\wwwroot\My Site\Views\Shared_Layout.cshtml Line: 13

Stack Trace:

[FileNotFoundException: Could not load file or assembly 'LibSassHost.Native-64.dll' or one of its dependencies. The specified module could not be found.]
System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence) +0
System.Reflection.Assembly.LoadFile(String path) +87
LibSassHost.AssemblyResolver.AssemblyResolveHandler(Object sender, ResolveEventArgs args) +479
System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName) +195

[FileNotFoundException: Could not load file or assembly 'LibSassHost.Native-Proxy, Version=0.4.1.0, Culture=neutral, PublicKeyToken=3e24e88796a38e46' or one of its dependencies. The specified module could not be found.]
LibSassHost.SassCompiler..ctor(IFileManager fileManager) +0
BundleTransformer.SassAndScss.Translators.SassAndScssTranslator.Translate(IList1 assets) +349 BundleTransformer.Core.Transformers.TransformerBase.Translate(IList1 assets, Boolean isDebugMode) +150
BundleTransformer.Core.Transformers.TransformerBase.Transform(IList1 assets, BundleContext bundleContext, BundleResponse bundleResponse, VirtualPathProvider virtualPathProvider, Boolean isDebugMode) +129 BundleTransformer.Core.Transformers.TransformerBase.Process(BundleContext bundleContext, BundleResponse bundleResponse, Boolean isDebugMode) +548 System.Web.Optimization.Bundle.ApplyTransforms(BundleContext context, String bundleContent, IEnumerable1 bundleFiles) +302
BundleTransformer.Core.Resolvers.CustomBundleResolver.GetBundleResponse(Bundle bundle, BundleContext context) +61
BundleTransformer.Core.Resolvers.CustomBundleResolver.GetBundleContents(String bundleVirtualPath) +205
System.Web.Optimization.AssetManager.EliminateDuplicatesAndResolveUrls(IEnumerable1 refs) +454 System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat, String[] paths) +35 ASP._Page_Views_Shared__Layout_cshtml.Execute() in D:\inetpub\wwwroot\Employee Toolkit\Views\Shared\_Layout.cshtml:13 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +253 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +148 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +122 System.Web.WebPages.<>c__DisplayClass3.<RenderPageCore>b__2(TextWriter writer) +311 System.Web.WebPages.WebPageBase.Write(HelperResult result) +108 System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action1 body) +89
System.Web.WebPages.WebPageBase.PopContext() +310
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +375
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +90 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList1 filters, ActionResult actionResult) +81 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +186 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38 System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +65
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +36 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +44 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +65
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +178

`@use` rule doesn't compile

Hi,

it seems to me that @use rules aren't correctly compiled:

foo.scss:

body {
    color: green;
}

bar.scss:

@use "foo";

I would expect the result to be

bar.css:

body {
    color: green;
}

However, I get

@use "foo";

Am I doing something wrong or is this a bug? I'm using version 1.3.1.

Updating System.Buffers in .Net Framework project breaks dll-mapping to libsasshost version

When updating System.Buffers from the dependency 4.0.0 to any newer version on nuget, the loading of LibSassHost-dll fails because of "missing System.Buffers 4.0.0" dll.

Could not load file or assembly 'System.Buffers, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Memory is corrupt

Activated Event Time Duration Thread
Exception thrown: 'System.AccessViolationException' in LibSassHost.Native-32.dll ("Attempted to read or write protected memory. This is often an indication that other memory is corrupt.") 8.17s [16180] Worker Thread

It happens frequently, for no rhyme or reason.

Use of LibSassHost in an Azure web App with server side compiling

Hello, as in the title I'm trying to implement a solution for compiling some scss to css on request in the backend in an Azure web App.

When requested I need to read the main scss file containing all the import from my server, modify the content of one of the imported files (is a colour string that needs to be replaced with a database fetched one) and then compile everything to a css string.

Is that possible with your library?

I've read through your code and is a really great job but I still have some doubts about the usage, thus my question.

greetings!

@import path resolution

I'm not sure whether this is the right place to post this, please redirect me if appropriate.

I've used BundleTransformer prior to version where it used libsass, and everything went OK. However, since I upgraded to LibSassHost 0.4.3-based version, it broke. I no longer can compile [
content/styles/components/popup.scss from this archive. I get "Exception in native code"

My investigations show that this is due to difference in @import path resolution. Parent file in my example is importing a mixin, that has another import in it. The problem is that import from mixin is resolved relatively to parent file, not relatively to mixin. The ticket in libSass is seems to have been closed and LibSassHost 0.4.3 seems to have added support for libSass 3.3.3.

Memory keeps growing

A simple (ASP.NET) stress test on below will make the RAM usage keep growing / memory corruption (all unmanaged memory)

using (var compiler = new SassCompiler()) {
  try {
    var result = compiler.Compile("p { color: red; }");
    ...

using CompileFile on bootstrap will cause it to grow more rapidly..

.. also (minor) it only run on 1 core (atomic lock).. any thoughts? async lock at least would be nice.. besides that - this lib is really nice! :)

P.S. this is listed on github as C++ and not C# - think the later should take precedence..

Using LibSass on MacOS

Hi! First, I need to congrats you for this lib. Really useful. So, I am porting and existing .net app to mono but i couldn't install 'LibSassHost.Native.osx-x64.1.0.4' there. Probably i am missing something.

I generated the build file described here: https://github.com/Taritsyn/LibSassHost#os-x, but the output generated was *.dylib, and i couldn't make it work on my project. If you could help me with that i really appreciate.

This is the error i got:

Could not install package 'LibSassHost.Native.osx-x64 1.0.4'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

edit:
I moved the generated file to: /Library/Frameworks/ and it's working.

tks!

On azure webapp getting "An attempt was made to load a program with an incorrect format"

I am trying to use LibSassHost in DotNetNuke cms and so far it's going good but when I host the code on azure webapp i am getting the below error.

I am using the latest version 1.3.1 and its working on my local and some other servers but not working on azure webapp.

Message :During loading of Sass compiler error has occurred. See the original error message: “An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)”.
StackTrace :
at LibSassHost.SassCompiler.Initialize() at LibSassHost.SassCompiler.InnerCompile(String content, Boolean indentedSyntax, String inputPath, String outputPath, String sourceMapPath, CompilationOptions options) at LibSassHost.SassCompiler.Compile(String content, String inputPath, String outputPath, String sourceMapPath, CompilationOptions options) at UXManager.Extensions.Apps.ThemeBuilder.Managers.ThemeManager.ProcessScss() at UXManager.Extensions.Apps.ThemeBuilder.Controllers.SettingsController.Save(String Guid, ThemeEditorData Data)

InnerMessage :An attempt was made to load a program with an incorrect format.(Exception from HRESULT: 0x8007000B)

InnerStackTrace : at LibSassHost.Internal.Native.Sass_Api.libsass_version() at LibSassHost.SassCompiler.Initialize()

Can't load "libsass" when running on docker for windows linux container .netcore 2

I have the following error when running on linux container. I added all libraries including debian but it still seems that Proxy class can't locate correct runtime for libsass library. I am running using Docker for Windows and Linux container, here is the version of it (seems it should be compatible):

Linux cbde0d8ca81d 4.9.49-moby #1 SMP Wed Sep 27 00:36:29 UTC 2017 x86_64 GNU/Linux
root@cbde0d8ca81d:/app# lbs_release -sirc
bash: lbs_release: command not found
root@cbde0d8ca81d:/app# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

I am running on .net core 2.0, can this be an issue? Any help is appreciated!

Compiler error: System.TypeInitializationException: The type initializer for 'LibSassHost.SassCompiler' threw an exception. ---> LibSassHost.SassCompilerLoadException: During loading of Sass-compiler error has occurred.

Most likely it happened, because failed to load the native implementation of the LibSass library. Therefore, you need to choose and install the most appropriate NuGet package(s) for your platform. The following packages are available:

* LibSassHost.Native.win-x86
* LibSassHost.Native.win-x64
* LibSassHost.Native.debian-x64
* LibSassHost.Native.osx-x64 ---> System.DllNotFoundException: Unable to load DLL 'libsass': The specified module or one of its dependencies could not be found.
 (Exception from HRESULT: 0x8007007E)
   at LibSassHost.Internal.Native.Sass_Api.libsass_version()
   at LibSassHost.Internal.SassCompilerProxy.GetVersion()
   at LibSassHost.SassCompiler..cctor()
   --- End of inner exception stack trace ---
   at LibSassHost.SassCompiler..cctor()
   --- End of inner exception stack trace ---
   at LibSassHost.SassCompiler.Compile(String content, CompilationOptions options)
   at VirtoCommerce.LiquidThemeEngine.ShopifyLiquidThemeEngine.GetAssetStream(String filePath) in c:\Projects\GitHub\vc-storefront-core\VirtoCommerce.LiquidThemeEngine\ShopifyLiquidThemeEngine.cs:line 185

Reduce the depencies

Hi

This is just a suggest/feature request. My company is using this library for our website. We are using webhotels and azure website. In this situation we can't install redistributable c++ 2017 as we don't have access to the machine.

So what I suggest is that the dependency be compiled into the libsass.dll as this will make the solution more portable. Perhaps as another set of dll's if people don't want the static linking.

The only change that needs to happen is set

  <RuntimeLibrary>MultiThreaded</RuntimeLibrary>

in libsass.vcxproj:

  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <Optimization>MaxSpeed</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;$(PreprocessorDefinitions);</PreprocessorDefinitions>
      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
    </ClCompile>

Thanks in advance

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

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;
		}
	}
}`

Error: File to import not found or unreadable

Hello

I recently updated LibSassHost in my project to 1.3.1 and with the following .scss file am getting an error. The bootstrap.scss file is in the same folder as the file with this code. Any help would be appreciated.

`
$enable-gradients: true;
$enable-shadows: true;
$enable-print-styles: false;

$blue: #337ab7;
$gray-100: #f5f5f5;

$border-radius: 4px;

$table-hover-bg: $blue;

$navbar-nav-link-padding-x: 15px;

$nav-link-padding-y: .833rem;
$nav-link-padding-x: 1.25rem;

@import "bootstrap";
`

the error is here:

BundleTransformer.Core.Translators.AssetTranslationException Occurred.


Message: During translation of SCSS code, readed from the file '/Rep/Content/bootstrap/custom.scss', to CSS code syntax error has occurred.
See more details:

Error: File to import not found or unreadable: bootstrap.
on line 17:1 of Content/bootstrap/custom.scss

@import "bootstrap";
^

Error code: 1
Description: File to import not found or unreadable: bootstrap.
File: /Rep/Content/bootstrap/custom.scss
Line number: 17
Column number: 1
Source fragment:

Line 17: @import "bootstrap";
---------^
Data:
TargetSite: Void InnerTranslate(BundleTransformer.Core.Assets.IAsset, LibSassHost.CompilationOptions, Boolean)
HelpLink: NULL
Source: BundleTransformer.SassAndScss
HResult: -2146233088

Stack Trace:


at BundleTransformer.SassAndScss.Translators.SassAndScssTranslator.InnerTranslate(IAsset asset, CompilationOptions sassOptions, Boolean enableNativeMinification)
at BundleTransformer.SassAndScss.Translators.SassAndScssTranslator.Translate(IList1 assets) at BundleTransformer.Core.Transformers.TransformerBase.Translate(IList1 assets, Boolean isDebugMode)
at BundleTransformer.Core.Transformers.TransformerBase.Transform(IList1 assets, BundleContext bundleContext, BundleResponse bundleResponse, VirtualPathProvider virtualPathProvider, Boolean isDebugMode) at BundleTransformer.Core.Transformers.TransformerBase.Process(BundleContext bundleContext, BundleResponse bundleResponse, Boolean isDebugMode) at BundleTransformer.Core.Transformers.TransformerBase.Process(BundleContext bundleContext, BundleResponse bundleResponse) at System.Web.Optimization.Bundle.ApplyTransforms(BundleContext context, String bundleContent, IEnumerable1 bundleFiles)
at System.Web.Optimization.Bundle.GenerateBundleResponse(BundleContext context)
at BundleTransformer.Core.Resolvers.CustomBundleResolver.GetBundleResponse(Bundle bundle, BundleContext context)
at BundleTransformer.Core.Resolvers.CustomBundleResolver.GetBundleContents(String bundleVirtualPath)
at System.Web.Optimization.AssetManager.DeterminePathsToRender(IEnumerable`1 assets)
at System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat, String[] paths)
at System.Web.Optimization.Styles.RenderFormat(String tagFormat, String[] paths)
at System.Web.Optimization.Styles.Render(String[] paths)
at Gwi.cSupport.Web.UI.PageBase.OnInit(EventArgs e) in C:\iSupport Source\iSupport\Main Trunk\Main Application\c.Support\Web\Framework\UI\PageBase.cs:line 72
at Gwi.cSupport.Web.UI.LicensedPageBase.OnInit(EventArgs e) in C:\iSupport Source\iSupport\Main Trunk\Main Application\c.Support\Web\Framework\UI\LicensedPageBase.cs:line 41
at System.Web.UI.Control.d__225.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Util.WithinCancellableCallbackTaskAwaitable.WithinCancellableCallbackTaskAwaiter.GetResult()
at System.Web.UI.Page.d__523.MoveNext()

C++ 2017 redistributable breaks libsass

The C++ 2017 redistributable replaces 2015 and that breaks libsass.

Previously where bootstrap.sass files compiled correctly it now failed with "File to import not found or unreadable: Modules/variables.
On this line.

@import "Modules/variables";

Nothing has been changed to any sass file.

Using

LibSassHost version v1.1.4 (was on 0.5.0) upgrading did not help
LibSassHost.Native.win-x64 v1.1.4

Conflict of using multiple sites in one application pool

hi!
I use libsasshost as handler for .scss files. It workes fine until I deployed second website in the same application pool (integrated mode). After 5-10 minutes, or when I change one of the partial .scss file (from "import" section of main .scss file), I get following error:

Object reference not set to an instance of an object.
2018-08-14 2 53 07

When I set second website to different app pool, everything is ok.

I use Custom descendant of VirtualPathProvider for website filesystem.

Architecture of our system assumes of using one app pool for multiple sites.
Is there any solution for our problem?

Microsoft Visual C++ 2010

According to the documentation, Microsoft Visual C++ 2015 is required to use this tool. For our company we are currently stuck on Microsoft Visual C++ 2010 (10.0.30319).
Will this tool also work with other Microsoft Visual C++ redistributables then 2015?

The type initializer for '<Module>' threw an exception.

Need a little help, please. I keep getting the error below when trying initialize and instance of SassCompiler. I have both x64 and x86 versions of Visual C++ Redistributable Packages for Visual Studio 2013 install. I have tried adding msvcp120.dll and msvcr120.dll to the bin manually as well as through Visual Studio (which failed because VS did not like the dll's) with no luck. I have google'ed and tried many other fixes and keep getting this error. Any suggestions or insite?

System.TypeInitializationException occurred
  HResult=0x80131534
  Message=The type initializer for '<Module>' threw an exception.
  Source=LibSassHost
  StackTrace:
   at LibSassHost.SassCompiler..ctor(IFileManager fileManager)
   at Scss.Editor.Plugin.Controllers.ScssFilesApiController.SaveFile(ScssFile scssFile) in D:\XXXXX\ScssFilesApiController.cs:line 269
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)

Inner Exception 1:
ModuleLoadException: The C++ module failed to load while attempting to initialize the default appdomain.

Error: media query expression must begin with '('

Scss-code to reproduce:

`@media all and (min-width: 901pt) { @import "l-xl.scss" }
@media all and (min-width: 601pt) and (max-width: 900pt) { @import "m-l.scss" }
@media all and (min-width: 241pt) and (max-width: 900pt) { @import "s-m.scss" }
@media all and (max-width: 900pt) { @import "xs-m.scss" }
@media all and (max-width: 600pt) { @import "xs-s.scss" }

@media all and (min-width: 1601pt) { @import "xl.scss" }
@media all and (min-width: 901pt) and (max-width: 1600pt) { @import "l.scss" }
@media all and (min-width: 601pt) and (max-width: 900pt) { @import "m.scss" }
@media all and (min-width: 241pt) and (max-width: 600pt) { @import "s.scss" }
@media all and (max-width: 240pt) { @import "xs.scss" }`

The error:
`Error: media query expression must begin with '(' on line 1 of
C:/Workspaces/ComparisComplete/Development/Source/netdata/commonroot/css/responsive/media.scss

                  { @import "l-xl.scss" }

------------------------------------------------------^`

Looks like this is an issue of libsass 3.3.2 see: sass/libsass#1766

When using PackageReference DLL is not copied (with fix)

Hi, after I changed nuget refs from packages.config to PackageReference the x64\libsass.dll is no longer copied to the bin\x64 folder.

I "reverted" this commits "condition" part here and then it works: abdf7ff

Not sure what the condition is meant to fix since I never experienced "problem with duplication of the native assemblies" - each platforms goes to own folder? And note that your fine JavaScriptEngineSwitcher hasn't got the condition either and works splendid :-)

Thanks!

.NET 6 on Apple Silicon

Now that .NET6 supports the arm64 architecture for Apple Silicon, I am trying to get the webcompiler tool (https://github.com/excubo-ag/WebCompiler) up and running on a Mac with an M1 processor.

Unfortunately, I run in this exception (thrown by LibSassHost):

 A compilation step encountered an exception During loading of Sass compiler error has occurred. Most likely it happened, because the 'libsass.dylib' assembly or one of its dependencies was not found. There is no LibSassHost.Native.osx-* package for the arm64 processor architecture. You can build the 'libsass.dylib' assembly for the current processor architecture by using following instructions - https://github.com/Taritsyn/LibSassHost#os-x-1. with stacktrace:
     at LibSassHost.SassCompiler.Initialize()
     at LibSassHost.SassCompiler.CompileFile(String inputPath, String outputPath, String sourceMapPath, CompilationOptions options)
     at WebCompiler.Compile.SassCompiler.Compile(List`1 file_sequence) in /home/runner/work/WebCompiler/WebCompiler/WebCompiler/Compile/SassCompiler.cs:line 71
     at WebCompiler.Compile.CompilationStep.With(Compiler compiler) in /home/runner/work/WebCompiler/WebCompiler/WebCompiler/Compile/CompilationStep.cs:line 22

I followed the mentioned steps and have the libsass.dylib in /usr/local/lib:

 ls -ali /usr/local/lib
total 5056
 807852 drwxr-xr-x  5 root  wheel      160 Nov 11 16:40 .
 348636 drwxr-xr-x  6 root  wheel      192 Nov 11 15:18 ..
 807914 drwxr-xr-x  3 root  wheel       96 Oct 26 13:10 dtrace
1040361 -rwxr-xr-x  1 root  wheel  2585460 Nov 11 16:40 libsass.dylib
 807853 drwxr-xr-x  8 root  wheel      256 Nov 11 16:29 node_modules

The libsass.dylib has been built locally on the same machine. Unfortunately, that does not help. Are there any other dependencies?

Mixin rendering problem

Hello!

I'm trying to use Bundle Transformer with SaasAndScss module in VS2015. When I try to use any mixin construction in SCSS code compiler fails with message: "Unhandled exception in native code". However, it compiles successfully another SCSS code without mixins. msvcp120.dll could not be the reason, because VC2013 redistributable is installed and SCSS code without mixins compiles successfully. I also tried to pass this SCSS file to node-sass npm package - it compiles it without any errors. Any workaround?

Best regards, Dmitry

P.S. Here is simple SCSS file contents which produces this error:
@mixin test-mix {
width: 1px;
}

Unhandled exceptions

We've started to use your extension in combination with our webapplications. So far we've managed to fix a lot of SCSS errors which we otherwise wouldn't have noticed.

But one thing seems odd to us; there's a lot of unhandled exceptions which prevent you from starting a debugging session with for example MVC .NET 4.7.1.

My questions is whether it is at all possible to catch these exceptions and pass / bubble them to the application. We already handle exceptions thrown by the sass compiler, but it seems some exceptions take place within your extension which we cannot handle. Is it at all possible to handle them one way or another?

Error:
An unhandled exception of type 'System.AccessViolationException' occurred in Unknown Module.
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Reproduction:

  • MVC .NET web application with sass.
  • Remove a trailing { on a random class.
  • Try to debug the application.

We'd love to hear your feedback!

Using custom transformers

Firstly, this library has been really useful so thanks for all the work. I have an issue that Im trying to work through. Here is the scenario,

Packages installed:
LibSassHost 1.0.0
LibSassHost.Native.win-x86 1.0.0

Im trying to dynamically add sass variables at runtime to the response content in a custom transformer, like so,

Bundle testCss = new Bundle("~/test/css").Include("~/test/test.scss");
testCss.Transforms.Add(new testTransformer());
testCss.Transforms.Add(new StyleTransformer());
bundles.Add(testCss);

In testTransformer, Im trying to add to response.content with some variables that override other variables.

public class testTransformer : IBundleTransform
{
	public void Process(BundleContext context, BundleResponse response)
	{
		//Variables to be pulled from a data store. Hard coding for now.
		response.Content = string.Format("{0}{1}", @"$primary: blue !default", response.Content);
	}
}

When I ran this, the transforms run correctly and the content is updated, but the bundletransformer library reads the file instead of the response content and completely ignores all other transforms.

It would be nice if it can read the response content instead of the file because the response content already has the contents from all the files in the bundle. MVC already gives us this. You could avoid an unnecessary file read and make the solution more extendible.

Is it possible to maybe add a configurable option to use content instead of reading the file again?

LibSassBuilder

Hi @Taritsyn - not sure where's best to reach you...

I've created this LibSassBuilder package as a replacement of the Delegate.SassBuilder in order to compile newer Sass files.

In my project I rely heavily on your LibSassHost packages, hence the name as well, and I'm wondering if you would like to take over ownership of it (my Sass knowledge is very limited)?

"Unable to find an entry point named 'libsass_version' in DLL 'libsass'." on Azure Web App

I'm seeing this error appear in our websites' ELMAH logs occasionally, and while it usually disappears pretty quickly, it recently persisted for many hours, resulting in one of our websites (thankfully a very low traffic one) being unavailable for some time.

I've looked through the code in this repository, and I don't see a way in which this issue can be fixed by a simple code change. However, I've elected to report it anyway, just in case someone else is having the same issue and can help shed more light on what exactly is happening. I'm also hoping that, if anyone has found a solution, they will elect to provide it on this issue.

I'm using the following NuGet packages (fully updated):

  • LibSassHost
  • LibSassHost.Native.win-x86

Unable to debug ASP.NET MVC project

Packages installed:
LibSassHost 1.0.0
LibSassHost.Native.win-x86 1.0.0

When running an ASP.NET MVC5 project in VS2015's debugger, the following error occurs:
Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 'C:\Program Files (x86)\IIS Express\iisexpress.exe'.

Additional information: A call to PInvoke function 'LibSassHost!LibSassHost.Internal.Native.Sass_Api::sass_file_manager_set_get_current_directory_delegate_utf16' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

Hopefully this is an easy fix 🙂

Not portable

Now that .NET is being ported everywhere others should be aware that this dependency will not work in non-Windows environments.

Would it be possible to have multiple binary builds available depending on the platform? Similar to https://www.npmjs.com/package/node-sass

When used inside a Microsoft.Build.Framework.ITask, the whole process crashes if there's an SCSS error

1>MSBUILD : error MSB4166: Child node "2" exited prematurely. Shutting down. Diagnostic information may be found in files in "C:\Users\tried\AppData\Local\Temp\" and will be named MSBuild_*.failure.txt. This location can be changed by setting the MSBUILDDEBUGPATH environment variable to a different directory.

This is the output when SassCompiler.Compile() is invoked and there's an error in the SCSS. Nonetheless there was no .txt file in the Temp folder specified above.

application o virtual directory

I have an application that uses SCSS and runs on a virtual directory.

When I use the LibSassHost.Native.win-x86 package in version 1.3.1, @imports with paths that do not use ~ in their path will stop working, while 1.2.10 works.

ex: http://localhost/app

[BUG] Upgrade to v1.3.1 adds `/c/` to paths

I upgraded to v1.3.1 - no other changes and got 404. Doing debug it seems that the path transferred to e.g. IFileManager.FileExists now starts with /c/client/ - I do not know where that c comes from - maybe from the first char in client.

Also some of the paths also go dobbelt slash end /stuff//

request: non-static file manager

Hello! I'm building a web application that uses LibSassHost. The one issue I ran into is that to specify a file manager, I have to plug it into the static property SassCompiler.FileManager. However, when you have multiple users on a website, each user may have different values current directory, folders and files available.

I considered using locks, though that would be a nasty quick that makes each user wait for everybody else. Slim semaphores would be better than locks, because they release threads, but still would make each user wait in line.

The ideal scenario would be to be able to pass the file manager in the parameter options of the compiler.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.