Closed chucklu closed 1 year ago
The above issue comes from WebGrease Microsoft.Ajax.Utilities public class Minifier packages\WebGrease.1.6.0\lib\WebGrease.dll
We're using Microsoft.AspNet.Web.Optimization,and it depends on WebGrease library.
source code https://webgrease.codeplex.com/
alternative tools https://github.com/dotnet/aspnetcore/issues/1604
Use NUglify or JSMin.NET.
This issue happened in Process method of JsMinify class of System.Web.Optimization library.
Minifier minifier = new Minifier();
string content = minifier.MinifyJavaScript(response.Content, new CodeSettings
{
EvalTreatment = EvalTreatment.MakeImmediateSafe,
PreserveImportantComments = false
});
Minifier class located in WebGrease.dll, and error happened in MinifyJavaScript method of Minifier class
System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Ajax.Utilities.Member.GetFunctionGuess(AstNode target) at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.GuessAtName(AstNode node) at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(FunctionObject node) at Microsoft.Ajax.Utilities.FunctionObject.Accept(IVisitor visitor) at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(BinaryOperator node) at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(Block node) at Microsoft.Ajax.Utilities.TreeVisitor.Visit(IfNode node) at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(IfNode node) at Microsoft.Ajax.Utilities.IfNode.Accept(IVisitor visitor) at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(Block node) at Microsoft.Ajax.Utilities.TreeVisitor.Visit(IfNode node) at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(IfNode node) at Microsoft.Ajax.Utilities.IfNode.Accept(IVisitor visitor) at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(Block node) at Microsoft.Ajax.Utilities.TreeVisitor.Visit(IfNode node) at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(IfNode node) at Microsoft.Ajax.Utilities.IfNode.Accept(IVisitor visitor) at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(Block node) at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(FunctionObject node) at Microsoft.Ajax.Utilities.FunctionObject.Accept(IVisitor visitor) at Microsoft.Ajax.Utilities.TreeVisitor.Visit(CallNode node) at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(CallNode node) at Microsoft.Ajax.Utilities.CallNode.Accept(IVisitor visitor) at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(Block node) at Microsoft.Ajax.Utilities.JSParser.InternalParse() at Microsoft.Ajax.Utilities.Minifier.MinifyJavaScript(String source, CodeSettings codeSettings) at System.Web.Optimization.JsMinify.Process(BundleContext context, BundleResponse response)
similar issue https://github.com/trullock/NUglify/issues/36
We have added a ScriptBundle of js file, and got exception
The file was downloaded from https://datatables.net/download/index
datatables.min.js.zip