Esempio n. 1
0
        public void Compile(MainWindowViewModel vm, CompilationFileViewModel compilationFileViewModel)
        {
            string file = compilationFileViewModel.File;
            compilationFileViewModel.Messages.Clear();

            Version ver;

            GetAndIncrementVersionFile(Path.GetDirectoryName(compilationFileViewModel.File), vm.IncrementVersion, out ver);

            string rewrittenFilePath = RewriteSourceFile(compilationFileViewModel.File, ver);

            try
            {
                using (var compiler = new Process())
                {
                    compiler.StartInfo.FileName = SettingsManager.CompilerLocation;
                    compiler.StartInfo.Arguments = string.Format(
                        "{0} -o=\"{1}\"",
                        rewrittenFilePath,
                        Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file)));

                    compiler.StartInfo.UseShellExecute = false;
                    compiler.StartInfo.RedirectStandardOutput = true;
                    compiler.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                    compiler.StartInfo.CreateNoWindow = true;
                    compiler.EnableRaisingEvents = true;
                    compiler.Start();

                    string output = compiler.StandardOutput.ReadToEnd();

                    if (File.Exists(rewrittenFilePath))
                    {
                        File.Delete(rewrittenFilePath);
                    }

                    if (!string.IsNullOrWhiteSpace(output))
                    {
                        foreach (CompilationMessage message in GetCompilationMessagesFromOutput(output.Split('\n')))
                        {
                            compilationFileViewModel.Messages.Add(message);
                        }
                    }

                    UpdateCompilationDataStatus(compilationFileViewModel);

                    if (!compilationFileViewModel.Messages.Any(m => CompilationMessageHelper.IsLineError(m.Prefix)) && SettingsManager.ExecutePostBuildScripts)
                    {
                        RunPostBuildScript(Path.GetDirectoryName(file));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 2
0
        public void CompileBatch(MainWindowViewModel vm)
        {
            vm.ProgressBarValue = 0;
            vm.ProgressBarMaximum = vm.FilesToCompile.Count;

            foreach (var compilationFile in vm.FilesToCompile)
            {
                UpdateCompilationDataStatus(compilationFile, isCompiling: true);
            }

            foreach (var compilationFile in vm.FilesToCompile)
            {
                Compile(vm, compilationFile);
                vm.ProgressBarValue++;
            }

            vm.ProgressBarValue = 0;
            SystemSounds.Asterisk.Play();
        }
Esempio n. 3
0
 public MainWindow()
 {
     InitializeComponent();
     DataContext = new MainWindowViewModel();
 }