including Closure Compiler into an asp.net app using command line

☆樱花仙子☆ 提交于 2019-12-23 20:31:57

问题


I have a method that I call on PageLoad of an aspx (the method will later be moved to a file in the AppCode dir) that looks like this:

public partial class PagesSystem_TestGCC : System.Web.UI.Page
{
     protected void Page_Load(object sender, EventArgs e)
     {
        string strCmdText;

        strCmdText = "/K java -jar c:\\TheSite\\compiler.jar --js      
                      c:\\TheSite\\JSTest\\hello.js --js_output_file
                      c:\\TheSite\\JSTest\\hello-compiled.js";

            System.Diagnostics.Process.Start("CMD.exe", strCmdText);
     }
}

The problem is that this approach relies on using the computer's file system. What do I need to change in my code to make it work with the application's root?

Thanks.


回答1:


the command line window flickers open and then closes, without a chance to see what's going on

Use "cmd.exe /K ... instead of "cmd.exe /C ....

I think that your actual problem is either access permissions or not having java.exe in the PATH of the ASP.Net user.

Use this code:

System.Diagnostics.Process.Start(
    new ProcessStartInfo {
        FileName = "java.exe",
        Arguments = "-jar compiler.jar --js JSTest/hello.js --js_output_file JSTest/hello-compiled.js",
        WorkingDirectory = HttpRuntime.AppDomainAppPath,
        UseShellExecute = false
    }
);



回答2:


open the windows command prompt and run the failed command there, so you will get a chance to note the exact error is throwing. Most probably the JAVA environment variables are not in place.



来源:https://stackoverflow.com/questions/20851606/including-closure-compiler-into-an-asp-net-app-using-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!