Skip to content

Commit

Permalink
An attempt was made to fix a error #26 “"Unable to find an entry poin…
Browse files Browse the repository at this point in the history
…t named 'libsass_version' in DLL 'libsass'." on Azure Web App”
  • Loading branch information
Taritsyn committed Dec 20, 2018
1 parent 45589ae commit 67aae28
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 24 deletions.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.1.500"
"version": "2.2.101"
}
}
5 changes: 1 addition & 4 deletions src/LibSassHost/Internal/SassCompilerProxy.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Reflection;

using LibSassHost.Internal.Native;
using LibSassHost.Internal.Native;

namespace LibSassHost.Internal
{
Expand Down
2 changes: 1 addition & 1 deletion src/LibSassHost/LibSassHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ This package does not contain the native implementations of LibSass. Therefore,
<RepositoryUrl>https://github.com/Taritsyn/LibSassHost</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>LibSass;Sass;SCSS;CSS</PackageTags>
<PackageReleaseNotes>Removed a generation of ID for instance of the file manager.</PackageReleaseNotes>
<PackageReleaseNotes>An attempt was made to fix a error #26 “"Unable to find an entry point named 'libsass_version' in DLL 'libsass'." on Azure Web App”.</PackageReleaseNotes>
<NeutralLanguage>en-US</NeutralLanguage>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
Expand Down
52 changes: 39 additions & 13 deletions src/LibSassHost/SassCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,27 @@ public static IFileManager FileManager
get { return _fileManager; }
set { _fileManager = value; }
}
#if !NETSTANDARD

/// <summary>
/// Static constructor
/// </summary>
/// <exception cref="SassCompilerLoadException">Failed to load a Sass-compiler.</exception>
static SassCompiler()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
try
{
AssemblyResolver.Initialize();
}
catch (InvalidOperationException e)
{
throw SassErrorHelpers.WrapCompilerLoadException(e);
}
}
}
#endif


/// <summary>
Expand All @@ -110,20 +131,7 @@ private static void Initialize()
{
return;
}
#if !NETSTANDARD

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
try
{
AssemblyResolver.Initialize();
}
catch (InvalidOperationException e)
{
throw SassErrorHelpers.WrapCompilerLoadException(e);
}
}
#endif
try
{
_version = SassCompilerProxy.GetVersion();
Expand All @@ -133,6 +141,24 @@ private static void Initialize()
{
throw WrapDllNotFoundException(e);
}
#if NETSTANDARD1_3
catch (TypeLoadException e)
#else
catch (EntryPointNotFoundException e)
#endif
{
string message = e.Message;
if (message.ContainsQuotedValue(DllName.Universal)
&& (message.ContainsQuotedValue("libsass_version") || message.ContainsQuotedValue("libsass_language_version")))
{
_version = "0.0.0";
_languageVersion = "0.0";
}
else
{
throw SassErrorHelpers.WrapCompilerLoadException(e, true);
}
}
catch (Exception e)
{
throw SassErrorHelpers.WrapCompilerLoadException(e, true);
Expand Down
3 changes: 2 additions & 1 deletion src/LibSassHost/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
=============
RELEASE NOTES
=============
Removed a generation of ID for instance of the file manager.
An attempt was made to fix a error #26 “"Unable to find an entry point named
'libsass_version' in DLL 'libsass'." on Azure Web App”.

============
PROJECT SITE
Expand Down
39 changes: 35 additions & 4 deletions test/LibSassHost.Test.Common/VersionInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,69 @@ public class VersionInfoTests
/// <summary>
/// Regular expression for working with the version of the LibSass library
/// </summary>
private static readonly Regex _versionRegex = new Regex(@"\d+(?:\.\d+){2}");
private static readonly Regex _versionRegex = new Regex(@"^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)$");

/// <summary>
/// Regular expression for working with the version of Sass language
/// </summary>
private static readonly Regex _languageVersionRegex = new Regex(@"\d+\.\d+");
private static readonly Regex _languageVersionRegex = new Regex(@"^(?<major>\d+)\.(?<minor>\d+)$");


[Fact]
public void VersionFormatIsCorrect()
{
// Arrange
bool formatIsCorrect = false;
int major = -1;
int minor = -1;
int patch = -1;

// Act
string version = SassCompiler.Version;
bool formatIsCorrect = _versionRegex.IsMatch(version);
Match match = _versionRegex.Match(version);

if (match.Success)
{
formatIsCorrect = true;

GroupCollection groups = match.Groups;
major = int.Parse(groups["major"].Value);
minor = int.Parse(groups["minor"].Value);
patch = int.Parse(groups["patch"].Value);
}

// Assert
Assert.True(formatIsCorrect);
Assert.True(major > 0);
Assert.True(minor >= 0);
Assert.True(patch >= 0);
}

[Fact]
public void LanguageVersionFormatIsCorrect()
{
// Arrange
bool formatIsCorrect = false;
int major = -1;
int minor = -1;

// Act
string languageVersion = SassCompiler.LanguageVersion;
bool formatIsCorrect = _languageVersionRegex.IsMatch(languageVersion);
Match match = _languageVersionRegex.Match(languageVersion);

if (match.Success)
{
formatIsCorrect = true;

GroupCollection groups = match.Groups;
major = int.Parse(groups["major"].Value);
minor = int.Parse(groups["minor"].Value);
}

// Assert
Assert.True(formatIsCorrect);
Assert.True(major > 0);
Assert.True(minor >= 0);
}
}
}

0 comments on commit 67aae28

Please sign in to comment.