Exemplo n.º 1
0
        private void Compile(string selectedPath)
        {
            if (string.IsNullOrEmpty(selectedPath))
            {
                return;
            }

            SettingHelper.LastPath             = Path.Text;
            SettingHelper.LastWorkingDirectory = WorkingDirectory.Text;

            InvokeReset();

            Defaults.Logger.WriteHeader("Compile Build File");

            string workingDir = WorkingDirectory.Text;
            //run on another thread to not block the message thread
            var d = new Action(delegate
            {
                if (!Directory.Exists(selectedPath))
                {
                    Defaults.Logger.WriteError("Folder Not Found", "Could not find the build folder at " + selectedPath);
                    return;
                }

                try
                {
                    _buildAssembly = CompilerService.BuildAssemblyFromSources(selectedPath, workingDir);
                    Dispatcher.BeginInvoke(new Action(delegate
                    {
                        Targets.ItemsSource   = CompilerService.FindBuildClasses(_buildAssembly);
                        Targets.SelectedIndex = 0;
                        InvokePropertyChanged("Targets");
                    }));
                }
                catch (Exception e)
                {
                    Defaults.Logger.WriteError("Compile Build File", e.ToString());
                }

                Defaults.Logger.WriteHeader("Done");
            });

            d.BeginInvoke(null, null);
        }