Example #1
0
        //
        public override bool Execute()
        {
            var errorStore = new XBuildErrorStore();

            try {
                var mxFilePath = CopyFile("Metah.X.cs", false);//EmbedSDOM);
                CopyFile("Metah.X.dll", false);
                if ((XCSharpFiles == null || XCSharpFiles.Length == 0) && (XFiles == null || XFiles.Length == 0))
                {
                    base.Log.LogMessage(MessageImportance.High, "Skip compilation");
                    return(true);
                }
                var xCSharpFileList = CreateCompilationInputFileList(XCSharpFiles);
                var xFileList       = CreateCompilationInputFileList(XFiles);
                var cSharpFileList  = CreateCompilationInputFileList(CSharpFiles);
                if (EmbedSDOM)
                {
                    cSharpFileList.Add(new CompilationInputFile(mxFilePath));
                }
                var preprocessorSymbolList = CreatePreprocessorSymbolList();
                var metadataReferenceList  = CreateMetadataReferenceList();
                var compilationInput       = new XCompilationInput(preprocessorSymbolList, cSharpFileList, metadataReferenceList, xCSharpFileList, xFileList);
                var compilationOutput      = XCompiler.Compile(compilationInput);
                foreach (var error in compilationOutput.ErrorList)
                {
                    LogError(error, errorStore);
                }
                if (compilationOutput.HasErrors)
                {
                    return(false);
                }
                var outputCSharpFileList = new List <TaskItem>();
                if (EmbedSDOM)
                {
                    outputCSharpFileList.Add(new TaskItem(mxFilePath));
                }
                if (compilationOutput.Analyzer != null)
                {
                    foreach (var compilationUnit in compilationOutput.Analyzer.CompilationUnits)
                    {
                        var filePath = compilationUnit.FilePath + ".cs";
                        File.WriteAllText(filePath, compilationUnit.CSText);
                        outputCSharpFileList.Add(new TaskItem(filePath));
                    }
                }
                OutputCSharpFiles = outputCSharpFileList.ToArray();
                return(true);
            }
            catch (Exception ex) {
                base.Log.LogErrorFromException(ex, true, true, null);
                return(false);
            }
            finally { errorStore.Save(ProjectDirectory); }
            //C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe D:\Test\TestPLX\TestPLX\TestPLX.csproj
            //v:detailed
        }
Example #2
0
        public string CompilePage(string pageFilePath, string GetVars = "", string PostVars = "")
        {
            try
            {
                string temp = System.IO.Path.GetTempFileName() + "." + AppHelper.LastPeice(pageFilePath, ".");

                if (this.DecodeDataBeforeEnvironment)
                {
                    GetVars = WebServer.DecodeUrlChars(GetVars);
                }

                if (GetVars.StartsWith("?"))
                {
                    GetVars = GetVars.Substring(1);
                }

                string prepend = XCompiler.PrependCode(this.LangName, (PostVars != "") ? "POST" : "GET");

                if (PostVars != "")
                {
                    prepend = prepend.Replace("GET", "POST");
                }

                AppHelper.writeToFile(temp, prepend + " \r\n\r\n" + AppHelper.ReadFileText(pageFilePath));
                pageFilePath = temp;

                Process proc = new Process();
                proc.StartInfo.FileName               = CompilerPath;
                proc.StartInfo.Arguments              = this.ProcessArgs.Replace("$page$", pageFilePath) + " " + GetVars + " " + PostVars;
                proc.StartInfo.CreateNoWindow         = true;
                proc.StartInfo.UseShellExecute        = false;
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.RedirectStandardError  = true;
                proc.Start();

                string res = proc.StandardOutput.ReadToEnd();
                if (string.IsNullOrEmpty(res))
                {
                    res = proc.StandardError.ReadToEnd();
                    res = "<h2 style=\"color:red;\">Error!</h2><hr/> <h4>Error Details :</h4> <pre>" + res + "</pre>";
                    proc.StandardError.Close();
                }
                if (res.StartsWith("\n Parse error: syntax error"))
                {
                    res = "<h2 style=\"color:red;\">Error!</h2><hr/> <h4>Error Details :</h4> <pre>" + res + "</pre>";
                }

                proc.StandardOutput.Close();
                proc.Close();

                AppHelper.deleteFile(temp);
                return(res);
            }
            catch (Exception s) { return(s.Message); }
        }
Example #3
0
        public FrmLanguageAdd(XCompiler LangList)
        {
            InitializeComponent();

            this.LangList = LangList;
        }
Example #4
0
        public FrmLanguageAdd(XCompiler LangList)
        {
            InitializeComponent();

            this.LangList = LangList;
        }