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); }
private static void Main(string[] args) { if (args.Length == 0 || args[0] == "/?" || args[0] == "/h") { Console.WriteLine("Usage: fb.exe BuildFileOrSource [-c:BuildClass] [-m:Method] [-p:property=value] [-p:property] [-v:Verbosity]"); Console.WriteLine(); Console.WriteLine("BuildFileOrSource: the dll that contains the precompiled build file OR the path to the source folder than contains build files (fb.exe will compile the build file for you)"); Console.WriteLine("c: The class to run. If none is specified then \"Default\" is assumed"); Console.WriteLine("p: properties to pass to the build script. These can be accessed via Properties.CommandLine in your build script. "); Console.WriteLine("v: verbosity of output. Can be None, TaskNamesOnly, TaskDetails, Full"); Console.WriteLine("m: Method to run. Allows a user to execute specific methods in the build. If specified only the method will run. Multiple specifications are allowed."); Environment.Exit(1); } AppDomain.CurrentDomain.UnhandledException += UnhandledException; Defaults.Logger.Verbosity = VerbosityLevel.TaskDetails; //creates a new parser and parses args var parser = new CommandLineParser(args); var argString = new StringBuilder(); foreach (string s in args) { argString.Append(" /" + s); } Defaults.Logger.Write("INIT", "running fb.exe " + argString); string pathToAssembly; if (parser.SourceBuild) { Defaults.Logger.Write("INIT", "building task from sources"); if (!Directory.Exists(parser.PathToBuildSources)) { Defaults.Logger.WriteError("ERROR", "Could not find sources at: " + parser.PathToBuildSources); Environment.Exit(1); } pathToAssembly = CompilerService.BuildAssemblyFromSources(parser.PathToBuildSources, Environment.CurrentDirectory); } else { pathToAssembly = parser.PathToBuildDll; } if (!File.Exists(pathToAssembly)) { Console.WriteLine("Could not find compiled build script at: " + parser.PathToBuildSources); Environment.Exit(1); } string output = CompilerService.ExecuteBuildTask(pathToAssembly, parser.ClassToRun, parser.MethodsToRun); if (output != string.Empty) { Console.WriteLine(output); Environment.Exit(1); } Environment.Exit(0); }