public async Task<BuildResult> Build (ProgressMonitor monitor, ConfigurationSelector configuration, bool buildReferencedTargets = false, OperationContext operationContext = null) { var res = new BuildResult { BuildCount = 0 }; foreach (var bt in Items.OfType<IBuildTarget> ()) res.Append (await bt.Build (monitor, configuration, operationContext:operationContext)); return res; }
/// <summary> /// Builds the specified solution item. /// </summary> /// <param name = "monitor">The monitor.</param> /// <param name = "item">The item.</param> /// <param name = "configuration">The configuration.</param> /// <returns>The build result.</returns> protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem item, ConfigurationSelector configuration) { BuildResult result = new BuildResult (); // Pre-build monitor.BeginTask (GettextCatalog.GetString ("Pre-Building..."), 1); this.PreBuild (result, monitor, item, configuration); monitor.EndTask(); if (result.ErrorCount > 0) { return result; } // Build monitor.BeginTask (GettextCatalog.GetString ("Building"), 1); result.Append (base.Build (monitor, item, configuration)); monitor.EndTask(); if (result.ErrorCount > 0) { return result; } // Post-build monitor.BeginTask (GettextCatalog.GetString ("Post-Building..."), 1); this.PostBuild (result, monitor, item, configuration); monitor.EndTask(); return result; }
public static BuildResult CompileXibFiles (IProgressMonitor monitor, IEnumerable<ProjectFile> files, FilePath outputRoot) { var result = new BuildResult (); var ibfiles = GetIBFilePairs (files, outputRoot).Where (NeedsBuilding).ToList (); if (ibfiles.Count > 0) { monitor.BeginTask (GettextCatalog.GetString ("Compiling interface definitions"), 0); foreach (var file in ibfiles) { file.EnsureOutputDirectory (); var args = new ProcessArgumentBuilder (); args.AddQuoted (file.Input); args.Add ("--compile"); args.AddQuoted (file.Output); var psi = new ProcessStartInfo ("ibtool", args.ToString ()); monitor.Log.WriteLine (psi.FileName + " " + psi.Arguments); psi.WorkingDirectory = outputRoot; string errorOutput; int code; try { code = ExecuteCommand (monitor, psi, out errorOutput); } catch (System.ComponentModel.Win32Exception ex) { LoggingService.LogError ("Error running ibtool", ex); result.AddError (null, 0, 0, null, "ibtool not found. Please ensure the Apple SDK is installed."); return result; } if (code != 0) { //FIXME: parse the plist that ibtool returns result.AddError (null, 0, 0, null, "ibtool returned error code " + code); } } monitor.EndTask (); } return result; }
public static BuildResult BuildProject(DubProject prj, IProgressMonitor mon, ConfigurationSelector sel) { var br = new BuildResult(); // Skip building sourceLibraries string targetType = null; var cfg = prj.GetConfiguration (sel) as DubProjectConfiguration; if (cfg != null){ cfg.BuildSettings.TryGetTargetTypeProperty (prj, sel, ref targetType); if(string.IsNullOrWhiteSpace(targetType)) prj.CommonBuildSettings.TryGetTargetTypeProperty (prj, sel, ref targetType); if (targetType != null && targetType.ToLower ().Contains("sourcelibrary")) { br.BuildCount = 1; return br; } } var args = new StringBuilder("build"); BuildCommonArgAppendix(args, prj, sel); string output; string errDump; int status = ProjectBuilder.ExecuteCommand(DubSettings.Instance.DubCommand, args.ToString(), prj.BaseDirectory, mon, out errDump, out output); br.CompilerOutput = output; ErrorExtracting.HandleReturnCode (mon, br, status); ErrorExtracting.HandleCompilerOutput(prj, br, output); ErrorExtracting.HandleCompilerOutput(prj, br, errDump); return br; }
protected override BuildResult OnBuild (MonoDevelop.Core.IProgressMonitor monitor, ConfigurationSelector configuration) { var restResult = RestClient.CompileScripts (); var result = new BuildResult (); foreach (var message in restResult.Messages) { var file = BaseDirectory + "/" + message.File; var msg = message.Message; var errorNum = ""; var messageStrings = message.Message.Split(':'); if (messageStrings.Length == 3) { var errorNumStrings = messageStrings[1].Split(' '); if (errorNumStrings.Length > 1) errorNum = errorNumStrings[errorNumStrings.Length - 1]; msg = messageStrings[2]; } if(message.Type == "warning") result.AddWarning(file, message.Line, message.Column, errorNum, msg); else result.AddError(file, message.Line, message.Column, errorNum, msg); } return result; }
public static BuildResult UpdateDesignerFile ( CodeBehindWriter writer, DotNetProject project, ProjectFile file, ProjectFile designerFile ) { var result = new BuildResult (); //parse the ASP.NET file var parsedDocument = TypeSystemService.ParseFile (project, file.FilePath).Result as WebFormsParsedDocument; if (parsedDocument == null) { result.AddError (string.Format ("Failed to parse file '{0}'", file.Name)); return result; } //TODO: ensure type system is up to date CodeCompileUnit ccu; result.Append (GenerateCodeBehind (project, designerFile.FilePath, parsedDocument, out ccu)); if (ccu != null) { writer.WriteFile (designerFile.FilePath, ccu); } return result; }
/// <summary> /// Scans errorString line-wise for filename-line-message patterns (e.g. "myModule(1): Something's wrong here") and add these error locations to the CompilerResults cr. /// </summary> public static void HandleCompilerOutput(AbstractDProject Project, BuildResult br, string errorString) { var reader = new StringReader(errorString); string next; while ((next = reader.ReadLine()) != null) { var error = ErrorExtracting.FindError(next, reader); if (error != null) { if (error.ErrorText != null && error.ErrorText.Length > MaxErrorMsgLength) error.ErrorText = error.ErrorText.Substring (0, MaxErrorMsgLength) + "..."; // dmd's error filenames may contain mixin location info var m = mixinInlineRegex.Match (error.FileName); if (m.Success) { error.FileName = error.FileName.Substring (0, m.Index); int line; int.TryParse (m.Groups ["line"].Value, out line); error.Line = line; } if (!Path.IsPathRooted(error.FileName)) error.FileName = Project.GetAbsoluteChildPath(error.FileName); br.Append(error); } } reader.Close(); }
public static void CompileXibs(IProgressMonitor monitor, BuildData buildData, BuildResult result) { var cfg = (MonobjcProjectConfiguration)buildData.Configuration; string appDir = ((MonobjcProjectConfiguration)buildData.Configuration).ResourcesDirectory; var ibfiles = GetIBFilePairs(buildData.Items.OfType<ProjectFile>(), appDir).Where(f => f.NeedsBuilding()).ToList(); if (ibfiles.Count > 0) { monitor.BeginTask(GettextCatalog.GetString("Compiling interface definitions"), 0); foreach (var file in ibfiles) { file.EnsureOutputDirectory(); var psi = new ProcessStartInfo("ibtool", String.Format("\"{0}\" --compile \"{1}\"", file.Input, file.Output)); monitor.Log.WriteLine(psi.FileName + " " + psi.Arguments); psi.WorkingDirectory = cfg.OutputDirectory; string errorOutput; int code = BuildUtils.ExecuteCommand(monitor, psi, out errorOutput); if (code != 0) { //FIXME: parse the plist that ibtool returns result.AddError(null, 0, 0, null, "ibtool returned error code " + code); } } monitor.EndTask(); } }
public static BuildResult ToBuildResult(this DiagnosticsMessage message) { var result = new BuildResult (); AddErrors (result.AddWarning, message.Warnings); AddErrors (result.AddError, message.Errors); return result; }
async Task<BuildResult> WaitForRestoreThenBuild (Task restoreTask, ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { try { await restoreTask; } catch (Exception ex) { var result = new BuildResult (); result.AddError (GettextCatalog.GetString ("{0}. Please see the Package Console for more details.", ex.Message)); return result; } return await base.OnBuild (monitor, configuration, operationContext); }
public void Compile (PythonProject project, FilePath fileName, PythonConfiguration config, BuildResult result) { if (String.IsNullOrEmpty (fileName)) throw new ArgumentNullException ("fileName"); else if (config == null) throw new ArgumentNullException ("config"); else if (result == null) throw new ArgumentNullException ("result"); else if (Runtime == null) throw new InvalidOperationException ("No supported runtime!"); // Get our relative path within the project if (!fileName.IsChildPathOf (project.BaseDirectory)) { Console.WriteLine ("File is not within our project!"); return; } FilePath relName = fileName.ToRelative (project.BaseDirectory); string outFile = relName.ToAbsolute (config.OutputDirectory); if (!outFile.EndsWith (".py")) return; // Create the destination directory FileInfo fileInfo = new FileInfo (outFile); if (!fileInfo.Directory.Exists) fileInfo.Directory.Create (); // Create and start our process to generate the byte code Process process = BuildCompileProcess (fileName, outFile, config.Optimize); process.Start (); process.WaitForExit (); // Parse errors and warnings string output = process.StandardError.ReadToEnd (); // Extract potential Warnings foreach (Match m in m_WarningRegex.Matches (output)) { string lineNum = m.Groups[m_WarningRegex.GroupNumberFromName ("line")].Value; string message = m.Groups[m_WarningRegex.GroupNumberFromName ("message")].Value; result.AddWarning (fileName, Int32.Parse (lineNum), 0, String.Empty, message); } // Extract potential SyntaxError foreach (Match m in m_ErrorRegex.Matches (output)) { string lineNum = m.Groups[m_ErrorRegex.GroupNumberFromName ("line")].Value; result.AddError (fileName, Int32.Parse (lineNum), 0, String.Empty, "SyntaxError"); } }
public static void Generate(IProgressMonitor monitor, BuildResult result, MonobjcProject project, ConfigurationSelector configuration, String outputDirectory, bool native) { // Infer application name from configuration String applicationName = project.GetApplicationName(configuration); LoggingService.LogInfo("Generate => applicationName='" + applicationName + "'"); LoggingService.LogInfo("Generate => outputDirectory='" + outputDirectory + "'"); // Create the bundle maker BundleMaker maker = new BundleMaker(applicationName, outputDirectory); // Compile the XIB files BuildHelper.CompileXIBFiles(monitor, project, maker, result); if (result.ErrorCount > 0) { monitor.ReportError(GettextCatalog.GetString("Failed to compile XIB files"), null); return; } // Copy the output and dependencies BuildHelper.CopyOutputFiles(monitor, project, configuration, maker); // Copy the content files BuildHelper.CopyContentFiles(monitor, project, configuration, maker); // Create the Info.plist BuildHelper.CreateInfoPList(monitor, project, configuration, maker); if (native) { GenerateNative(monitor, result, project, configuration, maker); } else { // Copy the Monobjc assemblies BuildHelper.CopyMonobjcAssemblies(monitor, project, configuration, maker); // Write the native runtime monitor.BeginTask(GettextCatalog.GetString("Copying native launcher..."), 0); maker.WriteRuntime(project.TargetOSVersion); monitor.EndTask(); } BuildHelper.CombineArtwork(monitor, project, maker); BuildHelper.EncryptContentFiles(monitor, project, configuration, maker); // Perform the signing BuildHelper.SignBundle(monitor, project, maker); BuildHelper.SignNativeBinaries(monitor, project, maker); }
public static void Archive(IProgressMonitor monitor, BuildResult result, MonobjcProject project, ConfigurationSelector configuration, String outputDirectory) { monitor.BeginTask(GettextCatalog.GetString("Archiving..."), 0); // Infer application name from configuration String applicationName = project.GetApplicationName(configuration); // Create the bundle maker BundleMaker maker = new BundleMaker(applicationName, outputDirectory); // Archive the application BuildHelper.ArchiveBundle(monitor, project, maker); monitor.EndTask(); }
/// <summary> /// Checks a compilation return code, /// and adds an error result if the compiler results /// show no errors. /// </summary> /// <param name="monitor"></param> /// <param name="br"> A <see cref="BuildResult"/>: The return code from a build run.</param> /// <param name="returnCode">A <see cref="System.Int32"/>: A process return code.</param> public static bool HandleReturnCode(IProgressMonitor monitor, BuildResult br, int returnCode) { if (returnCode != 0) { if (monitor != null) monitor.Log.WriteLine("Exit code " + returnCode.ToString()); if(br.ErrorCount == 0) br.AddError(string.Empty, 0, 0, string.Empty, GettextCatalog.GetString("Build failed - check build output for details")); return false; } return true; }
async Task<BuildResult> Pack (ProgressMonitor monitor, ConfigurationSelector configuration, bool buildReferencedTargets, OperationContext operationContext) { var result = new BuildResult (); // Build the project and any dependencies first. if (buildReferencedTargets && project.GetReferencedItems (configuration).Any ()) { result = await project.Build (monitor, configuration, buildReferencedTargets, operationContext); if (result.Failed) return result; } // Generate the NuGet package by calling the Pack target. var packResult = (await project.RunTarget (monitor, "Pack", configuration, new TargetEvaluationContext (operationContext))).BuildResult; return result.Append (packResult); }
public static BuildResult Compile( ProjectFile file, MonoDevelop.Core.IProgressMonitor monitor, BuildData buildData) { switch (file.BuildAction) { case "MonoGameShader": { var results = new BuildResult (); monitor.Log.WriteLine ("Compiling Shader"); monitor.Log.WriteLine ("Shader : " + buildData.Configuration.OutputDirectory); monitor.Log.WriteLine ("Shader : " + file.FilePath); monitor.Log.WriteLine ("Shader : " + file.ToString ()); return results; } default: return new BuildResult (); } }
static BuildResult ParseOut (string stdout, string stderr) { BuildResult result = new BuildResult (); StringBuilder compilerOutput = new StringBuilder (); bool typeLoadException = false; foreach (string s in new string[] { stdout, stderr }) { StreamReader sr = File.OpenText (s); while (true) { if (typeLoadException) { compilerOutput.Append (sr.ReadToEnd ()); break; } string curLine = sr.ReadLine(); compilerOutput.AppendLine (curLine); if (curLine == null) break; curLine = curLine.Trim(); if (curLine.Length == 0) continue; if (curLine.StartsWith ("Unhandled Exception: System.TypeLoadException") || curLine.StartsWith ("Unhandled Exception: System.IO.FileNotFoundException")) { //result.ClearErrors (); - something apparently not supported by this version of MD typeLoadException = true; } BuildError error = CreateErrorFromString (curLine); if (error != null) result.Append (error); } sr.Close(); } if (typeLoadException) { Regex reg = new Regex (@".*WARNING.*used in (mscorlib|System),.*", RegexOptions.Multiline); if (reg.Match (compilerOutput.ToString ()).Success) result.AddError ("", 0, 0, "", "Error: A referenced assembly may be built with an incompatible CLR version. See the compilation output for more details."); else result.AddError ("", 0, 0, "", "Error: A dependency of a referenced assembly may be missing, or you may be referencing an assembly created with a newer CLR version. See the compilation output for more details."); } result.CompilerOutput = compilerOutput.ToString (); return result; }
protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem project, ConfigurationSelector configuration) { var aspProject = project as AspNetAppProject; //get the config object and validate AspNetAppProjectConfiguration config = (AspNetAppProjectConfiguration)aspProject.GetConfiguration (configuration); if (config == null || config.DisableCodeBehindGeneration) { return base.Build (monitor, project, configuration); } var writer = CodeBehindWriter.CreateForProject (monitor, aspProject); if (!writer.SupportsPartialTypes) { return base.Build (monitor, project, configuration); } var result = new BuildResult (); monitor.BeginTask ("Updating CodeBehind designer files", 0); foreach (var file in aspProject.Files) { ProjectFile designerFile = CodeBehind.GetDesignerFile (file); if (designerFile == null) continue; if (File.GetLastWriteTimeUtc (designerFile.FilePath) > File.GetLastWriteTimeUtc (file.FilePath)) continue; monitor.Log.WriteLine ("Updating CodeBehind for file '{0}'", file); result.Append (CodeBehind.UpdateDesignerFile (writer, aspProject, file, designerFile)); } writer.WriteOpenFiles (); monitor.EndTask (); if (writer.WrittenCount > 0) monitor.Log.WriteLine ("{0} CodeBehind designer classes updated.", writer.WrittenCount); else monitor.Log.WriteLine ("No changes made to CodeBehind classes."); if (result.Failed) return result; return result.Append (base.Build (monitor, project, configuration)); }
public bool DoNativeBuild (IProgressMonitor monitor, BuildResult res) { var arch = EnsureMonoRuntime (monitor, res); if (arch == null) return false; var unversionedSo = CreateUnversionedSo (monitor, res); if (unversionedSo == null) return false; if (!DoNativeMake (monitor, res, arch)) return false; File.Delete (unversionedSo); if (!DoNativePackaging (monitor, res, arch)) return false; return true; }
public static BuildResult BuildProject(DubProject prj, IProgressMonitor mon, ConfigurationSelector sel) { var br = new BuildResult(); var args = new StringBuilder("build"); Instance.BuildCommonArgAppendix(args, prj, sel); string output; string errDump; int status = ProjectBuilder.ExecuteCommand(Instance.DubExecutable, args.ToString(), prj.BaseDirectory, mon, out errDump, out output); br.CompilerOutput = output; ErrorExtracting.HandleReturnCode(mon, br, status); ErrorExtracting.HandleCompilerOutput(prj, br, output); ErrorExtracting.HandleCompilerOutput(prj, br, errDump); return br; }
protected override BuildResult Build (IProgressMonitor monitor, IBuildTarget item, ConfigurationSelector configuration) { if (!(item is MonoDroidProject)) return base.Build (monitor, item, configuration); MonoDroidProject project = (MonoDroidProject) item; TargetFramework requiredFramework = Runtime.SystemAssemblyService.GetTargetFramework ("4.0"); // Check that we support 4.0 to infer we are at Mono 2.8 at least. if (!project.TargetRuntime.IsInstalled (requiredFramework)) { var message = "Mono 2.8 or newer is required."; MessageService.GenericAlert (MonoDevelop.Ide.Gui.Stock.MonoDevelop, message, "Mono 2.8 or newer is requiered. Please go to http://www.mono-project.com to update your installation.", AlertButton.Ok); var buildResult = new BuildResult (); buildResult.AddError (message); return buildResult; } return base.Build (monitor, item, configuration); }
protected async override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { if (Project.References.Count == 0 || !GtkDesignInfo.HasDesignedObjects (Project)) return await base.OnBuild (monitor, configuration, operationContext); Generator gen = new Generator (); if (!await gen.Run (monitor, Project, configuration)) { BuildResult gr = new BuildResult (); foreach (string s in gen.Messages) gr.AddError (DesignInfo.GuiBuilderProject.File, 0, 0, null, s); return gr; } BuildResult res = await base.OnBuild (monitor, configuration, operationContext); if (gen.Messages != null) { foreach (string s in gen.Messages) res.AddWarning (DesignInfo.GuiBuilderProject.File, 0, 0, null, s); if (gen.Messages.Length > 0) DesignInfo.ForceCodeGenerationOnBuild (); } if (res.Failed && !Platform.IsWindows && !Platform.IsMac) { // Some gtk# packages don't include the .pc file unless you install gtk-sharp-devel if (Project.AssemblyContext.GetPackage ("gtk-sharp-2.0") == null) { string msg = GettextCatalog.GetString ( "ERROR: MonoDevelop could not find the Gtk# 2.0 development package. " + "Compilation of projects depending on Gtk# libraries will fail. " + "You may need to install development packages for gtk-sharp-2.0."); monitor.Log.WriteLine (); monitor.Log.WriteLine (BrandingService.BrandApplicationName (msg)); } } return res; }
// Note: This must run in the main thread void PromptForSave (BuildResult result) { var couldNotSaveError = "The build has been aborted as the file '{0}' could not be saved"; foreach (var doc in IdeApp.Workbench.Documents) { if (doc.IsDirty && doc.Project != null) { if (MessageService.AskQuestion (GettextCatalog.GetString ("Save changed documents before building?"), GettextCatalog.GetString ("Some of the open documents have unsaved changes."), AlertButton.BuildWithoutSave, AlertButton.Save) == AlertButton.Save) { MarkFileDirty (doc.FileName); doc.Save (); if (doc.IsDirty) result.AddError (string.Format (couldNotSaveError, Path.GetFileName (doc.FileName)), doc.FileName); } else break; } } }
/// <summary> /// Compiles the XIB files. /// </summary> /// <param name = 'monitor'>The progress monitor.</param> /// <param name = 'project'>The project.</param> /// <param name = 'maker'>The bundle maker.</param> /// <param name = 'result'>The build result.</param> public static void CompileXIBFiles(IProgressMonitor monitor, MonobjcProject project, BundleMaker maker, BuildResult result) { XibCompiler xibCompiler = new XibCompiler (); IEnumerable<FilePair> files = project.GetIBFiles (Constants.InterfaceDefinition, maker.ResourcesFolder); if (files == null || files.Count() == 0) { return; } List<FilePair> pairs = new List<FilePair> (files); monitor.BeginTask (GettextCatalog.GetString ("Compiling XIB files..."), files.Count ()); foreach (FilePair pair in pairs) { monitor.Log.WriteLine (GettextCatalog.GetString ("Compiling {0}", pair.Source.ToRelative (project.BaseDirectory))); xibCompiler.Logger = new BuildLogger (pair.Source, monitor, result); xibCompiler.Compile (pair.Source, pair.DestinationDir); monitor.Step (1); } monitor.EndTask (); }
public BuildResult Build (ProgressMonitor monitor, ConfigurationSelector configuration) { BuildResult results = new BuildResult ("", 0, 0); string moFileName = GetOutFile (configuration); string moDirectory = Path.GetDirectoryName (moFileName); if (!Directory.Exists (moDirectory)) Directory.CreateDirectory (moDirectory); var pb = new ProcessArgumentBuilder (); pb.AddQuoted (PoFile); pb.Add ("-o"); pb.AddQuoted (moFileName); ProcessWrapper process = null; try { process = Runtime.ProcessService.StartProcess (GetTool ("msgfmt"), pb.ToString (), parentProject.BaseDirectory, monitor.Log, monitor.Log, null); } catch (System.ComponentModel.Win32Exception) { var msg = GettextCatalog.GetString ("Did not find msgfmt. Please ensure that gettext tools are installed."); monitor.ReportError (msg, null); results.AddError (msg); return results; } process.WaitForOutput (); if (process.ExitCode == 0) { monitor.Log.WriteLine (GettextCatalog.GetString ("Translation {0}: Compilation succeeded.", IsoCode)); } else { string message = GettextCatalog.GetString ("Translation {0}: Compilation failed. See log for details.", IsoCode); monitor.Log.WriteLine (message); results.AddError (PoFile, 1, 1, "", message); results.FailedBuildCount = 1; } return results; }
public int Run(string[] arguments) { Console.WriteLine("MonoDevelop Build Tool"); foreach (string s in arguments) { ReadArgument(s); } if (help) { Console.WriteLine("build [options] [build-file]"); Console.WriteLine("-p --project:PROJECT Name of the project to build."); Console.WriteLine("-t --target:TARGET Name of the target: Build or Clean."); Console.WriteLine("-c --configuration:CONFIGURATION Name of the solution configuration to build."); Console.WriteLine("-r --runtime:PREFIX Prefix of the Mono runtime to build against."); Console.WriteLine(); Console.WriteLine("Supported targets:"); Console.WriteLine(" {0}: build the project (the default target).", ProjectService.BuildTarget); Console.WriteLine(" {0}: clean the project.", ProjectService.CleanTarget); Console.WriteLine(); return(0); } string solFile = null; string itemFile = null; if (file == null) { string[] files = Directory.GetFiles("."); foreach (string f in files) { if (Services.ProjectService.IsWorkspaceItemFile(f)) { solFile = f; break; } else if (itemFile == null && Services.ProjectService.IsSolutionItemFile(f)) { itemFile = f; } } if (solFile == null && itemFile == null) { Console.WriteLine("Project file not found."); return(1); } } else { if (Services.ProjectService.IsWorkspaceItemFile(file)) { solFile = file; } else if (Services.ProjectService.IsSolutionItemFile(file)) { itemFile = file; } else { Console.WriteLine("File '{0}' is not a project or solution.", file); return(1); } } IProgressMonitor monitor = new ConsoleProjectLoadProgressMonitor(new ConsoleProgressMonitor()); TargetRuntime targetRuntime = null; TargetRuntime defaultRuntime = Runtime.SystemAssemblyService.DefaultRuntime; if (runtime != null) { targetRuntime = MonoTargetRuntimeFactory.RegisterRuntime(new MonoRuntimeInfo(runtime)); if (targetRuntime != null) { Runtime.SystemAssemblyService.DefaultRuntime = targetRuntime; } } IBuildTarget item; if (solFile != null) { item = Services.ProjectService.ReadWorkspaceItem(monitor, solFile); } else { item = Services.ProjectService.ReadSolutionItem(monitor, itemFile); } if (project != null) { Solution solution = item as Solution; item = null; if (solution != null) { item = solution.FindProjectByName(project); } if (item == null) { Console.WriteLine("The project '" + project + "' could not be found in " + file); return(1); } } IConfigurationTarget configTarget = item as IConfigurationTarget; if (config == null && configTarget != null) { config = configTarget.DefaultConfigurationId; } ConfigurationSelector configuration; if (item is SolutionEntityItem) { configuration = new ItemConfigurationSelector(config); } else { configuration = new SolutionConfigurationSelector(config); } monitor = new ConsoleProgressMonitor(); BuildResult res = item.RunTarget(monitor, command, configuration); if (targetRuntime != null) { Runtime.SystemAssemblyService.DefaultRuntime = defaultRuntime; MonoTargetRuntimeFactory.UnregisterRuntime((MonoTargetRuntime)targetRuntime); } if (res != null) { foreach (var err in res.Errors) { Console.Error.WriteLine(err); } } return((res == null || res.ErrorCount == 0) ? 0 : 1); }
/// <summary> /// Embeds the XIB files. /// </summary> /// <param name = 'monitor'>The progress monitor.</param> /// <param name = 'project'>The project.</param> /// <param name = 'maker'>The bundle maker.</param> /// <param name = 'result'>The build result.</param> public static void EmbedXIBFiles(IProgressMonitor monitor, MonobjcProject project, BuildResult result) { XibCompiler xibCompiler = new XibCompiler (); IEnumerable<FilePair> files = project.GetIBFiles (Constants.EmbeddedInterfaceDefinition, null); if (files == null || files.Count() == 0) { return; } monitor.BeginTask (GettextCatalog.GetString ("Embed XIB files..."), files.Count ()); foreach (FilePair pair in files) { // If the destination file is a place-holder, change its dates FileInfo sourceInfo = new FileInfo (pair.Source); FileInfo destInfo = new FileInfo (pair.Destination); if (destInfo.Length == 0) { DateTime dateTime = sourceInfo.CreationTime.Subtract (new TimeSpan (0, 0, 1)); File.SetCreationTime (pair.Destination, dateTime); File.SetLastAccessTime (pair.Destination, dateTime); File.SetLastWriteTime (pair.Destination, dateTime); } FilePath relativeFile = pair.Source.ToRelative (project.BaseDirectory); monitor.Log.WriteLine (GettextCatalog.GetString ("Compiling {0}", relativeFile)); xibCompiler.Logger = new BuildLogger (pair.Source, monitor, result); xibCompiler.Compile (pair.Source, pair.DestinationDir); monitor.Step (1); } monitor.EndTask (); }
/// <summary> /// Builds the solution item /// </summary> /// <param name='monitor'> /// A progress monitor /// </param> /// <param name='solutionConfiguration'> /// Configuration to use to build the project /// </param> /// <param name='buildReferences'> /// When set to <c>true</c>, the referenced items will be built before building this item /// </param> public BuildResult Build(IProgressMonitor monitor, ConfigurationSelector solutionConfiguration, bool buildReferences) { ITimeTracker tt = Counters.BuildProjectTimer.BeginTiming("Building " + Name); try { if (!buildReferences) { //SolutionFolder's OnRunTarget handles the begin/end task itself, don't duplicate if (this is SolutionFolder) { return(RunTarget(monitor, ProjectService.BuildTarget, solutionConfiguration)); } try { SolutionEntityItem it = this as SolutionEntityItem; SolutionItemConfiguration iconf = it != null?it.GetConfiguration(solutionConfiguration) : null; string confName = iconf != null ? iconf.Id : solutionConfiguration.ToString(); monitor.BeginTask(GettextCatalog.GetString("Building: {0} ({1})", Name, confName), 1); // This will end calling OnBuild () return(RunTarget(monitor, ProjectService.BuildTarget, solutionConfiguration)); } finally { monitor.EndTask(); } } // Get a list of all items that need to be built (including this), // and build them in the correct order List <SolutionItem> referenced = new List <SolutionItem> (); Set <SolutionItem> visited = new Set <SolutionItem> (); GetBuildableReferencedItems(visited, referenced, this, solutionConfiguration); ReadOnlyCollection <SolutionItem> sortedReferenced = SolutionFolder.TopologicalSort(referenced, solutionConfiguration); BuildResult cres = new BuildResult(); cres.BuildCount = 0; HashSet <SolutionItem> failedItems = new HashSet <SolutionItem> (); monitor.BeginTask(null, sortedReferenced.Count); foreach (SolutionItem p in sortedReferenced) { if (!p.ContainsReferences(failedItems, solutionConfiguration)) { BuildResult res = p.Build(monitor, solutionConfiguration, false); cres.Append(res); if (res.ErrorCount > 0) { failedItems.Add(p); } } else { failedItems.Add(p); } monitor.Step(1); if (monitor.IsCancelRequested) { break; } } monitor.EndTask(); return(cres); } finally { tt.End(); } }
protected internal override Task OnEndBuildOperation(ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext, BuildResult result) { EndBuildCalled?.Invoke(); return(base.OnEndBuildOperation(monitor, configuration, operationContext, result)); }
void BuildDone (IProgressMonitor monitor, BuildResult result, IBuildTarget entry, ITimeTracker tt) { Task[] tasks = null; tt.Trace ("Begin reporting build result"); try { if (result != null) { lastResult = result; monitor.Log.WriteLine (); monitor.Log.WriteLine (GettextCatalog.GetString ("---------------------- Done ----------------------")); tt.Trace ("Updating task service"); tasks = new Task [result.Errors.Count]; for (int n=0; n<tasks.Length; n++) { tasks [n] = new Task (result.Errors [n]); tasks [n].Owner = this; } TaskService.Errors.AddRange (tasks); TaskService.Errors.ResetLocationList (); IdeApp.Workbench.ActiveLocationList = TaskService.Errors; tt.Trace ("Reporting result"); string errorString = GettextCatalog.GetPluralString("{0} error", "{0} errors", result.ErrorCount, result.ErrorCount); string warningString = GettextCatalog.GetPluralString("{0} warning", "{0} warnings", result.WarningCount, result.WarningCount); if (result.ErrorCount == 0 && result.WarningCount == 0 && lastResult.FailedBuildCount == 0) { monitor.ReportSuccess (GettextCatalog.GetString ("Build successful.")); } else if (result.ErrorCount == 0 && result.WarningCount > 0) { monitor.ReportWarning(GettextCatalog.GetString("Build: ") + errorString + ", " + warningString); } else if (result.ErrorCount > 0) { monitor.ReportError(GettextCatalog.GetString("Build: ") + errorString + ", " + warningString, null); } else { monitor.ReportError(GettextCatalog.GetString("Build failed."), null); } tt.Trace ("End build event"); OnEndBuild (monitor, lastResult.FailedBuildCount == 0, lastResult, entry as SolutionItem); } else { tt.Trace ("End build event"); OnEndBuild (monitor, false); } tt.Trace ("Showing results pad"); try { Pad errorsPad = IdeApp.Workbench.GetPad<MonoDevelop.Ide.Gui.Pads.ErrorListPad> (); switch (IdeApp.Preferences.ShowErrorPadAfterBuild) { case BuildResultStates.Always: if (!errorsPad.Visible) errorsPad.IsOpenedAutomatically = true; errorsPad.Visible = true; errorsPad.BringToFront (); break; case BuildResultStates.Never: break; case BuildResultStates.OnErrors: if (TaskService.Errors.Any (task => task.Severity == TaskSeverity.Error)) goto case BuildResultStates.Always; goto case BuildResultStates.Never; case BuildResultStates.OnErrorsOrWarnings: if (TaskService.Errors.Any (task => task.Severity == TaskSeverity.Error || task.Severity == TaskSeverity.Warning)) goto case BuildResultStates.Always; goto case BuildResultStates.Never; } } catch {} if (tasks != null) { Task jumpTask = null; switch (IdeApp.Preferences.JumpToFirstErrorOrWarning) { case JumpToFirst.Error: jumpTask = tasks.FirstOrDefault (t => t.Severity == TaskSeverity.Error && TaskStore.IsProjectTaskFile (t)); break; case JumpToFirst.ErrorOrWarning: jumpTask = tasks.FirstOrDefault (t => (t.Severity == TaskSeverity.Error || t.Severity == TaskSeverity.Warning) && TaskStore.IsProjectTaskFile (t)); break; } if (jumpTask != null) { tt.Trace ("Jumping to first result position"); jumpTask.JumpToPosition (); } } } finally { monitor.Dispose (); tt.End (); } }
/// <summary> /// Builds the project. /// </summary> /// <returns> /// The build result. /// </returns> /// <param name='monitor'> /// Progress monitor. /// </param> /// <param name='configuration'> /// Configuration to build. /// </param> /// <remarks> /// This method is invoked to build the project. Support files such as files with the Copy to Output flag will /// be copied before calling this method. /// </remarks> protected virtual BuildResult DoBuild(IProgressMonitor monitor, ConfigurationSelector configuration) { BuildResult res = ItemHandler.RunTarget(monitor, "Build", configuration); return(res ?? new BuildResult()); }
// Note: This must run in the main thread void SaveAllFiles (BuildResult result) { var couldNotSaveError = "The build has been aborted as the file '{0}' could not be saved"; foreach (var doc in new List<MonoDevelop.Ide.Gui.Document> (IdeApp.Workbench.Documents)) { if (doc.IsDirty && doc.Project != null) { doc.Save (); if (doc.IsDirty) result.AddError (string.Format (couldNotSaveError, Path.GetFileName (doc.FileName)), doc.FileName); } } }
protected override Task <BuildResult> OnClean(ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { return(Task.FromResult(BuildResult.CreateSuccess())); }
internal static async Task <BuildResult> RunParallelBuildOperation(ProgressMonitor monitor, ConfigurationSelector configuration, IEnumerable <SolutionItem> sortedItems, Func <ProgressMonitor, SolutionItem, Task <BuildResult> > buildAction, bool ignoreFailed) { List <SolutionItem> toBuild = new List <SolutionItem> (sortedItems); BuildResult cres = new BuildResult(); cres.BuildCount = 0; // Create a dictionary with the status objects of all items var buildStatus = ImmutableDictionary <SolutionItem, BuildStatus> .Empty; foreach (var it in toBuild) { buildStatus = buildStatus.Add(it, new BuildStatus()); } // Start the build tasks for all itemsw foreach (var itemToBuild in toBuild) { if (monitor.CancellationToken.IsCancellationRequested) { break; } var item = itemToBuild; var myStatus = buildStatus [item]; var myMonitor = monitor.BeginAsyncStep(1); // Get a list of the status objects for all items on which this one depends var refStatus = item.GetReferencedItems(configuration).Select(it => { BuildStatus bs; buildStatus.TryGetValue(it, out bs); return(bs); }).Where(t => t != null).ToArray(); // Build the item when all its dependencies have been built var refTasks = refStatus.Select(bs => bs.Task); myStatus.Task = Task.WhenAll(refTasks).ContinueWith(async t => { if (!ignoreFailed && (refStatus.Any(bs => bs.Failed) || t.IsFaulted)) { myStatus.Failed = true; } else { myStatus.Result = await buildAction(myMonitor, item); myStatus.Failed = myStatus.Result != null && myStatus.Result.ErrorCount > 0; } myMonitor.Dispose(); }, Runtime.MainTaskScheduler).Unwrap(); if (!Runtime.Preferences.ParallelBuild.Value) { await myStatus.Task; } } // Wait for all tasks to end await Task.WhenAll(buildStatus.Values.Select(bs => bs.Task)); // Generate the errors in the order they were supposed to build foreach (var it in toBuild) { BuildStatus bs; if (buildStatus.TryGetValue(it, out bs) && bs.Result != null) { cres.Append(bs.Result); } } return(cres); }
public TargetEvaluationResult(BuildResult buildResult) { this.buildResult = buildResult; }
public TargetEvaluationResult(BuildResult buildResult, IEnumerable <IMSBuildItemEvaluated> items, IReadOnlyPropertySet properties) { this.buildResult = buildResult; this.items = items; this.properties = properties; }
BuildResult DoBeforeCompileAction () { BeforeCompileAction action = IdeApp.Preferences.BeforeBuildSaveAction; var result = new BuildResult (); switch (action) { case BeforeCompileAction.Nothing: break; case BeforeCompileAction.PromptForSave: DispatchService.GuiDispatch (delegate { PromptForSave (result); }); break; case BeforeCompileAction.SaveAllFiles: DispatchService.GuiDispatch (delegate { SaveAllFiles (result); }); break; default: System.Diagnostics.Debug.Assert (false); break; } return result; }
internal protected virtual Task OnEndBuildOperation(ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext, BuildResult result) { return(next.OnEndBuildOperation(monitor, configuration, operationContext, result)); }
void OnEndBuild (IProgressMonitor monitor, bool success, BuildResult result = null, SolutionItem item = null) { if (EndBuild == null) return; var args = new BuildEventArgs (monitor, success) { SolutionItem = item }; if (result != null) { args.WarningCount = result.WarningCount; args.ErrorCount = result.ErrorCount; args.BuildCount = result.BuildCount; args.FailedBuildCount = result.FailedBuildCount; } EndBuild (this, args); }
public void BuildingAndCleaning() { string solFile = Util.GetSampleProject("console-with-libs", "console-with-libs.sln"); Solution sol = (Solution)Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile); DotNetProject p = (DotNetProject)sol.FindProjectByName("console-with-libs"); DotNetProject lib1 = (DotNetProject)sol.FindProjectByName("library1"); DotNetProject lib2 = (DotNetProject)sol.FindProjectByName("library2"); SolutionFolder folder = new SolutionFolder(); folder.Name = "subfolder"; sol.RootFolder.Items.Add(folder); sol.RootFolder.Items.Remove(lib2); folder.Items.Add(lib2); Workspace ws = new Workspace(); ws.FileName = Path.Combine(sol.BaseDirectory, "workspace"); ws.Items.Add(sol); ws.Save(Util.GetMonitor()); // Build the project and the references BuildResult res = ws.Build(Util.GetMonitor(), "Debug"); Assert.AreEqual(0, res.ErrorCount); Assert.AreEqual(0, res.WarningCount); Assert.AreEqual(3, res.BuildCount); Assert.IsTrue(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", "console-with-libs.exe"))); Assert.IsTrue(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", GetMdb("console-with-libs.exe")))); Assert.IsTrue(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", "library1.dll"))); Assert.IsTrue(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", GetMdb("library1.dll")))); Assert.IsTrue(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", "library2.dll"))); Assert.IsTrue(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", GetMdb("library2.dll")))); // Clean the workspace ws.Clean(Util.GetMonitor(), "Debug"); Assert.IsFalse(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", "console-with-libs.exe"))); Assert.IsFalse(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", GetMdb("console-with-libs.exe")))); Assert.IsFalse(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", "library1.dll"))); Assert.IsFalse(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", GetMdb("library1.dll")))); Assert.IsFalse(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", "library2.dll"))); Assert.IsFalse(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", GetMdb("library2.dll")))); // Build the solution res = ws.Build(Util.GetMonitor(), "Debug"); Assert.AreEqual(0, res.ErrorCount); Assert.AreEqual(0, res.WarningCount); Assert.AreEqual(3, res.BuildCount); Assert.IsTrue(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", "console-with-libs.exe"))); Assert.IsTrue(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", GetMdb("console-with-libs.exe")))); Assert.IsTrue(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", "library1.dll"))); Assert.IsTrue(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", GetMdb("library1.dll")))); Assert.IsTrue(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", "library2.dll"))); Assert.IsTrue(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", GetMdb("library2.dll")))); // Clean the solution sol.Clean(Util.GetMonitor(), "Debug"); Assert.IsFalse(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", "console-with-libs.exe"))); Assert.IsFalse(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", GetMdb("console-with-libs.exe")))); Assert.IsFalse(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", "library1.dll"))); Assert.IsFalse(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", GetMdb("library1.dll")))); Assert.IsFalse(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", "library2.dll"))); Assert.IsFalse(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", GetMdb("library2.dll")))); // Build the solution folder res = folder.Build(Util.GetMonitor(), (SolutionConfigurationSelector)"Debug"); Assert.AreEqual(0, res.ErrorCount); Assert.AreEqual(0, res.WarningCount); Assert.AreEqual(1, res.BuildCount); Assert.IsFalse(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", "console-with-libs.exe"))); Assert.IsFalse(File.Exists(Util.Combine(p.BaseDirectory, "bin", "Debug", GetMdb("console-with-libs.exe")))); Assert.IsFalse(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", "library1.dll"))); Assert.IsFalse(File.Exists(Util.Combine(lib1.BaseDirectory, "bin", "Debug", GetMdb("library1.dll")))); Assert.IsTrue(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", "library2.dll"))); Assert.IsTrue(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", GetMdb("library2.dll")))); // Clean the solution folder folder.Clean(Util.GetMonitor(), (SolutionConfigurationSelector)"Debug"); Assert.IsFalse(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", "library2.dll"))); Assert.IsFalse(File.Exists(Util.Combine(lib2.BaseDirectory, "bin", "Debug", GetMdb("library2.dll")))); }