BundleTransformer.Less unable to parse variables in #import statements - c#

EDIT:
So according to this it is not possible which is a real shame. I will need to look for a library that bundles and compresses with the support of variables in imports.
I am having trouble trying to get BundleTransformer.Less to parse the following LESS:
// There is a path to Startup framework
#startup-basePath: "../../../";
#import '#{startup-basePath}flat-ui/less/config.less';
#import '#{startup-basePath}flat-ui/less/mixins.less';
And it is producing the following error:
You are importing a file ending in .less that cannot be found.":"/lib/startup/samples/template/less/#{startup-basePath}flat-ui/less/config.less
The files does exist but as you can see it isn't parsing the variable in the location string. Web Essentials in VS2013 has no problem compiling the LESS files and output the CSS as expected. I suspect the issue lies with BundleTransformer or the way that have set it up. I am using the following version:
Id Version Description/Release Notes
-- ------- -------------------------
BundleTransformer.Core 1.8.0 Bundle Transformer - a modular extension for System.Web.Optimization (aka Microsoft ASP.NET Web Optimization Framework). Classes `CssTransformer` and `JsTra...
BundleTransformer.Less 1.7.16 BundleTransformer.Less contains translator-adapter LessTranslator. This adapter makes translation of LESS-code to CSS-code. Also contains HTTP-handler LessA...
BundleTransformer.Yui 1.8.0 BundleTransformer.Yui contains 2 minifier-adapters: `YuiCssMinifier` (for minification of CSS-code) and `YuiJsMinifier` (for minification of JS-code). These...
I have to use these versions as I am using Umbraco 7 and it will not allow me to update Newtonsoft.Json without breaking Umbraco.
My bundle config file looks like the following:
public static void RegisterBundles(BundleCollection bundles)
{
bundles.UseCdn = true;
var nullBuilder = new NullBuilder();
var nullOrderer = new NullOrderer();
// CSS + LESS
var libCSS = new CustomStyleBundle("~/libCSS");
libCSS.Include(
"~/Content/font-awesome.css",
// LESS
"~/lib/startup/samples/template/less/style.less");
libCSS.Orderer = nullOrderer;
bundles.Add(libCSS);
}
I assumed that the issue was with the Less transformer not being registered correctly but I have followed the installation instructions to the letter, please see the documentation for the LESS version. Can anybody see something that I am missing that would help solve this issue or could anyone recommend something that I could try?
All help appreciated.

I have also tried this library, but unsuccessfully :/
Best solution for compiling LESS are node.js packages LESS (https://www.npmjs.org/package/less) or Recess (http://twitter.github.io/recess/).
Because your LESS files won't be changed after you deploy web project, you don't have to generate css during each application initialization.
You can also generate CSS before application builds or after saving LESS file.
If you're interested i can help you with more informations.

I have had better luck with the 1.9.40 and 1.9.34 versions of these BundleTransformer packages. I had problems with the 1.8 versions failing at times. We've been using BundleTransformer.Core.1.9.40, BundleTransformer.Less.1.9.40, and BundleTransformer.Yui.1.9.34 for a couple of weeks now without any of the errors of the 1.8 versions.

BundleTransformer.Less does not support the string interpolation in file paths (see «Is string interpolation not supported?» discussion).
UPDATE: In BundleTransformer.Less version 1.9.92 now supports the interpolation in file paths.

Related

Command line tool to generate C# .Net Framework client for an Open API specification. Note: It is not for C# .Net Core [duplicate]

I have a .net core 2.2 Class Library.
I have installed the VS Studio 2017 "OpenAPI (Swagger) Connected Service" extension.
I have attempted to use this extension to generate a c# client for the following API:
https://skybox.vividseats.com/services/openapi.json
The extension runs and builds a number of files:
But, when I build the project I have 1640 errors:
It appears to have generated all the functions and named then as 1Async, 2Async etc....
Can anyone see anything wrong that I am doing? Or suggest another method to generate a client from the url?
Any help would be greatly appreciated!
You may want to try OpenAPI Generator to generate C# .NET Core client:
Download latest stable version v4.1.3: http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.1.3/openapi-generator-cli-4.1.3.jar, and rename it as openapi-generator-cli.jar
java -jar openapi-generator-cli.jar generate -g csharp-netcore -i https://skybox.vividseats.com/services/openapi.json -o /var/tmp/ --skip-validate-spec
I can build the project without issue. Please test it to see if it works for you.
There are spec validation errors so I use --skip-validate-spec to skip those errors. Please review those errors when you've time.
There are other ways to install OpenAPI Generator: https://github.com/OpenAPITools/openapi-generator#1---installation
UPDATE: we've added a csharp-netcore client generator. Please check out the latest master of v5.0.0 release to give it a try.
I've finally found a solution to this problem.
The solution is to define OperationId for every endpoint.
You can do this in different ways, I think it's the best described here.
I do this in the SwaggerDefaultValues:
var controllerActionDescriptor = (ControllerActionDescriptor)apiDescription.ActionDescriptor;
var controllerName = controllerActionDescriptor.ControllerName;
var actionName = controllerActionDescriptor.ActionName;
operation.OperationId ??= $"{controllerName}{actionName}";
It's important to note that operation id SHOULD NOT contain underscores.

C#, IronPython error: IronPython.Runtime.Exceptions.ImportException - No module named requests

Using VS 2019 I installed the nuget packages IronPython v2.7.11 and DynamicLanguageRuntime v1.3.0 and am trying to run a python script. It ran fine until I added imports to the script:
import requests, time, socket
import random
Here’s the C#:
static void Main(string[] args)
{
DateTime start = DateTime.Now;
ScriptEngine engine = Python.CreateEngine();
var searchPaths = engine.GetSearchPaths();
// Path to where everything is installed for this Python enviroment
searchPaths.Add(#"C:\Users\George\.conda\envs\spenv2");
int url_id = 1701;
string url = "https://www.yellowpages.com/search?search_terms=Health&geo_location_terms=Aliso+Viejo%2C+CA";
ScriptScope scope = engine.CreateScope();
engine.ExecuteFile(#"D:\Apps\Data Destinations\Scraping\ScrapeProjects\Job1.v4_For_IronPython_CSharp\ScrapeUrlPages.py", scope);
dynamic testFunction = scope.GetVariable("scrape_all_pages_for_this_search");
dynamic result = testFunction(url_id, url);
Console.WriteLine(result);
}
I found a few posts regarding similar issues and the solution most of them was to add search paths. Which I did:
searchPaths.Add(#"C:\Users\George\.conda\envs\spenv2");
This is where everything is installed for the Python environment, spendv2, is being used.
Any recommendations on what I need to do?
Thank you.
The problem is an incompatibility between IronPython and Python and the more I dug into this the more problems I found.
Not documented anywhere but I found someone from the IronPython crew who pointed out that IronPython 2.7.11 "Must" interact with Python 2.7. Hmmm. 2.7 hit end-of-life a long time ago and you can't even download it from the Python site.
Not documented anywhere that I could find but IronPython 3.4 (just released) "Must" interact with Python 3.4, and yes, 3.4 hit end-of-life a long time ago and you can't even download it from the Python site. I find this odd that a new release of something would be based on something obsolete.
I was able to get Python 2.7.n from nuget and after getting everything setup and configured, and set all the new paths, I was able to get c# to execute a python script via ironpython. The script had the “import requests” and it did run – where as before when attempting to execute the script I would get the error:
IronPython.Runtime.Exceptions.ImportException - No module named requests
The script runs now – yippy - but – the python script gets an exception when calling the requests.get() method. The exception is:
"not expecting type '<type 'bytes'>'" object {string}
Evidently, from my searches, "not expecting type '<type 'bytes'>'" is a result of an incompatibility with the requests module and IronPython. There are about 5 well known python modules that are not compatible with IronPython so when it get called it returns a blob of bytes.
In conclusion, to the best of my knowledge you cannot call python requests from c#
I hope this helps someone as it cost me several long painful days.
What I see is you're using the get for the searchpaths so you load the collection of strings but what is missing is the engine.SetSearchPaths(searchPaths); to get it working.
I know that this is an old post, but I found something that works for me that can help in future questions about this.
I installed IronPython.StdLib from the NuGet Package.
I downloaded the needed library (Tkinter) with my IDE (PyCharm) and then I added the folder to the Lib folder in my C# project.
I added
var libs = new[] {#"{PATH OF YOUR PROJECT}\Lib"};
engine.SetSearchPaths(libs);
And that works for me.

Unable to find an entry point named 'sk_color_get_bit_shift' in DLL 'libSkiaSharp'. when using SkiaSharp 15.9.1

I am attempting to build and use the MicoCharts project available here: https://github.com/dotnet-ad/Microcharts which is dependant on this SkiaSharp project available here: https://github.com/mono/SkiaSharp
The specific version I am attempting to use is 15.9.1 (the version that the nuget package downloads) which utilizes skia m59.
I need to build them myself and cannot use Nuget due to business restrictions, just use the package isn't an option for me.
I have built skia m59, SkiaSharp and MicroCharts but when I attempt to create a SKBitmap object I get an error when it attempts to initialize SkiaSharp.SKImageInfo. The error is as follows:
Unable to find an entry point named 'sk_color_get_bit_shift' in DLL 'libSkiaSharp'.
I had to make a few changes to the base BUILD.gn to point to the correct file locations, for the windows SDK and the VC install. I enabled skia_use_gdi in the BUILD.gn and ran the following commands.
python2 tools/git-sync-deps
gn gen out/Release --args="is_debug=false is_official_build=true skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false skia_use_icu=false is_component_build=true"
ninja -C out/Release skia
This process outputs a DLL I assumed is the same as the libSkiaSharp that the SkiaSharp project relies on. I add all my references and run, the project runs successfully until I attempt to create the SkBitmap object then it fails.
Either this DLL is not the correct DLL and I am misunderstanding something here or something in my process is wrong. I would love any help I can get as I am completely new to building these sorts of projects, I am a C# developer by trade.
This is not the same thing. SkiaSharp has a few other bits that it adds to the core skia. The output that you would have got is a skia.dll, which only part. Not sure how you got a libSkiaSharp from the skia target...
If you can't use SkiaSharp from NuGet.org (which is the supported case) you can follow this to build your own: https://github.com/mono/SkiaSharp/wiki/Building-SkiaSharp
You can also check out the Azure DevOps yaml: https://github.com/mono/SkiaSharp/blob/master/scripts/azure-pipelines.yml
Just set up your own DevOps job to use that and all the work will be done for you.

Tesseract 3 (OCR) - .NET Wrapper

http://code.google.com/p/tesseractdotnet/
I am having a problem getting Tesseract to work in my Visual Studio 2010 projects. I have tried console and winforms and both have the same outcome. I have come across a dll by someone else who claims to have it working in VS2010:
http://code.google.com/p/tesseractdotnet/issues/detail?id=1
I am adding a reference to the dll which can be found in the attached to post 64 from the website above. Every time I build my project I get an AccessViolationException saying that an attempt was made to read or write protected memory.
public void StartOCR()
{
const string language = "eng";
const string TessractData = #"C:\Users\Joe\Desktop\tessdata\";
using (TesseractProcessor processor = new TesseractProcessor())
{
using (Bitmap bmp = Bitmap.FromFile(fileName) as Bitmap)
{
if (processor.Init(TessractData, language, (int)eOcrEngineMode.OEM_DEFAULT))
{
string text = processor.Recognize(bmp);
}
}
}
}
The access violation exception always points to if (processor.Init(TessractData, language, (int)eOcrEngineMode.OEM_DEFAULT)). I've seen a few suggestions to make sure the solution platform is set to x86 in the configuration manager and that the tessdata folder location is finished with trailing slash, to no avail. Any ideas?
It appeared to be the contents of the tessdata folder that was causing the problem. Obtained the tessdata folder from the first link and all is now working.
I have just completed a project with tesseract engine 3. i think, there is a bug in the engine, that need to be rectified. What i Did to remove "AccessViolationError" is, add "\tessdata" to the real tessdata directory string. I don't know why, but the engine seems to be truncating the innermost directory in the Tessdata path.
Just made Full OCR package (Dlls+Tessdata(english)) that works with .net framework 4.
If somebody has the same problem and advice with trailing slash doesn't work, try... TWO ending slashes! Seriosly. It works for me.
if (processor.Init(#".\tessdata\\", "eng", (int)eOcrEngineMode.OEM_DEFAULT))
Seems your problem relates to stability issue mentioned here. On the official site there is a recommendation to use previous stable release 2.4.1. You can install it from nuget.org via the package manager command: Install-Package Tesseract -Version 2.4.1

Is it possible to use DLR in a .NET 3.5 website project?

I'm trying to evaluate an expression stored in a database i.e.
"if (Q1 ==2) {result = 3.1;} elseif (Q1 ==3){result=4.1;} else result = 5.9;"
Rather than parsing it myself I'm trying to use the DLR. I'm using version .92 from the Codeplex repository and my solution is a .NET 3.5 website; and I'm having conflicts between the System.Core and Microsoft.Scripting.ExtenstionAttribute .dll's.
Error =
{
Description: "'ExtensionAttribute' is ambiguous in the namespace 'System.Runtime.CompilerServices'.",
File: "InternalXmlHelper.vb"
}
At this time I cannot upgrade to .NET 4.0 and make significant use of the .net 3.5 features (so downgrading is not an option).
Any help greatly appreciated.
The solution is to type forward ExtensionAttribte into System.Core.dll. We've made 3 different versions of this assembly (for the 3 different versions that we've shipped w/ various IronPython versions) and attached to them on this bug on IronPython's CodePlex site.
You'll need to download them and check the versions on them and replace the one that matches the version in the CodePlex release you're using.
I might be to complex thinking right now and more easy solutions exists, but this jumped into my mind as a possibility;
Have you considered building a runtime class using the CodeDom, instanciating one, executing a method on it (with the expression as its implementation, which is more like code-snippets than a pure expression) and then retrieving the 'result' value from that class instance via a public property?

Categories