protected override BuildResult OnBuild(IProgressMonitor monitor, ConfigurationSelector configuration) { var r = new BuildResult(); r.AddError("Project unavailable"); return(r); }
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; }
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; }
protected override BuildResult OnBuild(IProgressMonitor monitor, ConfigurationSelector configuration) { BuildResult res = new BuildResult(); res.AddError("Unknown project type"); return(res); }
protected override Task <BuildResult> OnBuild(ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { var r = new BuildResult(); r.AddError(UnsupportedProjectMessage); return(Task.FromResult(r)); }
protected override Task <BuildResult> OnBuild(ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { var r = new BuildResult(); r.AddError("Project unavailable"); return(Task.FromResult(r)); }
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; }
public override BuildResult RunTarget(IProgressMonitor monitor, string target, ConfigurationSelector configuration) { if (!TargetRuntime.IsInstalled(TargetFramework)) { BuildResult res = new BuildResult(); res.AddError(GettextCatalog.GetString("Framework '{0}' not installed.", TargetFramework.Name)); return(res); } return(base.RunTarget(monitor, target, configuration)); }
protected override BuildResult OnBuild(IProgressMonitor monitor, ConfigurationSelector configuration) { // create output directory, if not exists ProjectConfiguration conf = GetConfiguration(configuration) as ProjectConfiguration; if (conf == null) { BuildResult cres = new BuildResult(); cres.AddError(GettextCatalog.GetString("Configuration '{0}' not found in project '{1}'", configuration.ToString(), Name)); return(cres); } StringParserService.Properties["Project"] = Name; if (UsingMSBuildEngine()) { var r = DoBuild(monitor, configuration); isDirty = false; return(r); } string outputDir = conf.OutputDirectory; try { DirectoryInfo directoryInfo = new DirectoryInfo(outputDir); if (!directoryInfo.Exists) { directoryInfo.Create(); } } catch (Exception e) { throw new ApplicationException("Can't create project output directory " + outputDir + " original exception:\n" + e.ToString()); } //copy references and files marked to "CopyToOutputDirectory" CopySupportFiles(monitor, configuration); monitor.Log.WriteLine("Performing main compilation..."); BuildResult res = DoBuild(monitor, configuration); isDirty = false; if (res != null) { string errorString = GettextCatalog.GetPluralString("{0} error", "{0} errors", res.ErrorCount, res.ErrorCount); string warningString = GettextCatalog.GetPluralString("{0} warning", "{0} warnings", res.WarningCount, res.WarningCount); monitor.Log.WriteLine(GettextCatalog.GetString("Build complete -- ") + errorString + ", " + warningString); } return(res); }
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); }
/// <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; }
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; }
protected override BuildResult OnBuild (IProgressMonitor monitor, ConfigurationSelector configuration) { // create output directory, if not exists ProjectConfiguration conf = GetConfiguration (configuration) as ProjectConfiguration; if (conf == null) { BuildResult cres = new BuildResult (); cres.AddError (GettextCatalog.GetString ("Configuration '{0}' not found in project '{1}'", configuration.ToString (), Name)); return cres; } string outputDir = conf.OutputDirectory; try { DirectoryInfo directoryInfo = new DirectoryInfo (outputDir); if (!directoryInfo.Exists) { directoryInfo.Create (); } } catch (Exception e) { throw new ApplicationException ("Can't create project output directory " + outputDir + " original exception:\n" + e.ToString ()); } //copy references and files marked to "CopyToOutputDirectory" CopySupportFiles (monitor, configuration); StringParserService.Properties["Project"] = Name; monitor.BeginTask (GettextCatalog.GetString ("Performing main compilation..."), 0); BuildResult res = DoBuild (monitor, configuration); isDirty = false; if (res != null) { string errorString = GettextCatalog.GetPluralString ("{0} error", "{0} errors", res.ErrorCount, res.ErrorCount); string warningString = GettextCatalog.GetPluralString ("{0} warning", "{0} warnings", res.WarningCount, res.WarningCount); monitor.Log.WriteLine (GettextCatalog.GetString ("Build complete -- ") + errorString + ", " + warningString); } monitor.EndTask (); return res; }
BuildResult DoBeforeCompileAction () { var result = new BuildResult (); var couldNotSaveError = "The build has been aborted as the file '{0}' could not be saved"; BeforeCompileAction action = IdeApp.Preferences.BeforeBuildSaveAction; switch (action) { case BeforeCompileAction.Nothing: break; case BeforeCompileAction.PromptForSave: 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; } } break; case BeforeCompileAction.SaveAllFiles: 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); } break; default: System.Diagnostics.Debug.Assert(false); break; } return result; }
/// <summary> /// Checks a compilation return code, /// and adds an error result if the compiler results /// show no errors. /// </summary> /// <param name="returnCode"> /// A <see cref="System.Int32"/>: A process return code /// </param> /// <param name="cr"> /// A <see cref="CompilerResults"/>: The return code from a compilation run /// </param> void HandleReturnCode(BuildResult br, string executable, int returnCode) { if (returnCode != 0) { if (monitor != null) monitor.Log.WriteLine ("Exit code " + returnCode.ToString ()); br.AddError (string.Empty, 0, 0, string.Empty, GettextCatalog.GetString ("Build failed - check build output for details")); } }
protected override BuildResult OnBuild (IProgressMonitor monitor, ConfigurationSelector configuration) { BuildResult res = new BuildResult (); res.AddError ("Unknown project type"); return res; }
/// <summary> /// Compiles a D project. /// </summary> public BuildResult Build(DProject Project, ConfigurationSelector BuildConfigurationSelector) { this.Project = Project; BuildConfig = Project.GetConfiguration (BuildConfigurationSelector) as DProjectConfiguration; commonMacros = new PrjPathMacroProvider { slnPath = Project.ParentSolution.BaseDirectory }; BuiltObjects.Clear (); if (Compiler == null) { var targetBuildResult = new BuildResult (); targetBuildResult.AddError ("Project compiler \"" + Project.UsedCompilerVendor + "\" not found"); targetBuildResult.FailedBuildCount++; return targetBuildResult; } if (Path.IsPathRooted (BuildConfig.ObjectDirectory)) AbsoluteObjectDirectory = BuildConfig.ObjectDirectory; else AbsoluteObjectDirectory = Path.Combine (Project.BaseDirectory, EnsureCorrectPathSeparators (BuildConfig.ObjectDirectory)); if (!Directory.Exists (AbsoluteObjectDirectory)) Directory.CreateDirectory (AbsoluteObjectDirectory); if (CanDoOneStepBuild) return DoOneStepBuild (); else return DoStepByStepBuild (); }
bool CompileResourceScript(BuildResult targetBuildResult, ProjectFile f) { var res = GetRelativeObjectFileName (BuildConfig.ObjectDirectory, f, ".res"); // Build argument string var resCmpArgs = FillInMacros (Win32ResourceCompiler.Instance.Arguments, new Win32ResourceCompiler.ArgProvider { RcFile = f.FilePath, ResFile = res },commonMacros); // Execute compiler string output; string stdOutput; int _exitCode = ExecuteCommand (Win32ResourceCompiler.Instance.Executable, resCmpArgs, Project.BaseDirectory, monitor, out output, out stdOutput); // Error analysis if (!string.IsNullOrEmpty (output)) targetBuildResult.AddError (f.FilePath, 0, 0, "", output); if (!string.IsNullOrEmpty (stdOutput)) targetBuildResult.AddError (f.FilePath, 0, 0, "", stdOutput); HandleReturnCode (targetBuildResult, Win32ResourceCompiler.Instance.Executable, _exitCode); if (_exitCode != 0) { targetBuildResult.FailedBuildCount++; return false; } else { f.LastGenOutput = res; targetBuildResult.BuildCount++; Project.LastModificationTimes [f] = File.GetLastWriteTime (f.FilePath); BuiltObjects.Add (MakeRelativeToPrjBase (res)); return true; } }
public static BuildResult GenerateCodeBehind ( AspNetAppProject project, string filename, AspNetParsedDocument document, out CodeCompileUnit ccu) { ccu = null; var result = new BuildResult (); string className = document.Info.InheritedClass; foreach (var err in document.Errors) result.AddError (filename, err.Region.BeginLine, err.Region.BeginColumn, null, err.Message); if (result.ErrorCount > 0) return result; if (string.IsNullOrEmpty (className)) return result; var refman = new DocumentReferenceManager (project) { Doc = document }; var memberList = new MemberListBuilder (refman, document.XDocument); memberList.Build (); foreach (var err in memberList.Errors) result.AddError (filename, err.Region.BeginLine, err.Region.BeginColumn, null, err.Message); if (result.ErrorCount > 0) return result; //initialise the generated type ccu = new CodeCompileUnit (); var namespac = new CodeNamespace (); ccu.Namespaces.Add (namespac); var typeDecl = new CodeTypeDeclaration { IsClass = true, IsPartial = true, }; namespac.Types.Add (typeDecl); //name the class and namespace int namespaceSplit = className.LastIndexOf ('.'); if (namespaceSplit > -1) { namespac.Name = project.StripImplicitNamespace (className.Substring (0, namespaceSplit)); typeDecl.Name = className.Substring (namespaceSplit + 1); } else { typeDecl.Name = className; } string masterTypeName = null; if (!String.IsNullOrEmpty (document.Info.MasterPageTypeName)) { masterTypeName = document.Info.MasterPageTypeName; } else if (!String.IsNullOrEmpty (document.Info.MasterPageTypeVPath)) { try { ProjectFile resolvedMaster = project.ResolveVirtualPath (document.Info.MasterPageTypeVPath, document.FileName); AspNetParsedDocument masterParsedDocument = null; if (resolvedMaster != null) masterParsedDocument = TypeSystemService.ParseFile (project, resolvedMaster.FilePath) as AspNetParsedDocument; if (masterParsedDocument != null && !String.IsNullOrEmpty (masterParsedDocument.Info.InheritedClass)) masterTypeName = masterParsedDocument.Info.InheritedClass; } catch (Exception ex) { LoggingService.LogWarning ("Error resolving master page type", ex); } if (string.IsNullOrEmpty (masterTypeName)) { var msg = string.Format ("Could not find type for master '{0}'", document.Info.MasterPageTypeVPath); result.AddError (filename, msg); return result; } } if (masterTypeName != null) { var masterProp = new CodeMemberProperty { Name = "Master", Type = new CodeTypeReference (masterTypeName), HasGet = true, HasSet = false, Attributes = MemberAttributes.Public | MemberAttributes.New | MemberAttributes.Final, }; masterProp.GetStatements.Add (new CodeMethodReturnStatement ( new CodeCastExpression (masterTypeName, new CodePropertyReferenceExpression ( new CodeBaseReferenceExpression (), "Master")))); typeDecl.Members.Add (masterProp); } //shortcut building the existing members type map if (memberList.Members.Count == 0) return result; var dom = refman.TypeCtx.Compilation; var cls = ReflectionHelper.ParseReflectionName (className).Resolve (dom); var members = GetDesignerMembers (memberList.Members.Values, cls, filename); //add fields for each control in the page foreach (var member in members) { var type = new CodeTypeReference (member.Type.FullName); typeDecl.Members.Add (new CodeMemberField (type, member.Name) { Attributes = MemberAttributes.Family }); } return result; }
public BuildResult Compile (ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, ProgressMonitor monitor) { VBCompilerParameters compilerparameters = (VBCompilerParameters) configuration.CompilationParameters; if (compilerparameters == null) compilerparameters = new VBCompilerParameters (); var projectparameters = (VBProject) configuration.ParentItem; string exe = configuration.CompiledOutputName; string responseFileName = Path.GetTempFileName(); StreamWriter writer = new StreamWriter (responseFileName); writer.WriteLine (GenerateOptions (configuration, compilerparameters, projectparameters, exe)); // Write references foreach (ProjectReference lib in items.GetAll<ProjectReference> ()) { foreach (string fileName in lib.GetReferencedFileNames (configSelector)) { writer.Write ("\"-r:"); writer.Write (fileName); writer.WriteLine ("\""); } } // Write source files and embedded resources foreach (ProjectFile finfo in items.GetAll<ProjectFile> ()) { if (finfo.Subtype != Subtype.Directory) { switch (finfo.BuildAction) { case "Compile": writer.WriteLine("\"" + finfo.Name + "\""); break; case "EmbeddedResource": string fname = finfo.Name; if (String.Compare (Path.GetExtension (fname), ".resx", true) == 0) fname = Path.ChangeExtension (fname, ".resources"); writer.WriteLine("\"-resource:{0},{1}\"", fname, finfo.ResourceId); break; default: continue; } } } // Write source files and embedded resources foreach (Import import in items.GetAll<Import> ()) { writer.WriteLine ("-imports:{0}", import.Include); } TempFileCollection tf = new TempFileCollection (); writer.Close(); string output = ""; string compilerName = configuration.TargetRuntime.GetToolPath (configuration.TargetFramework, "vbc"); if (compilerName == null) { BuildResult res = new BuildResult (); res.AddError (string.Format ("Visual Basic .NET compiler not found ({0})", configuration.TargetRuntime.DisplayName)); return res; } string workingDir = "."; if (configuration.ParentItem != null) workingDir = configuration.ParentItem.BaseDirectory; int exitCode; var envVars = configuration.TargetRuntime.GetToolsExecutionEnvironment (configuration.TargetFramework); monitor.Log.WriteLine (Path.GetFileName (compilerName) + " " + string.Join (" ", File.ReadAllLines (responseFileName))); exitCode = DoCompilation (compilerName, responseFileName, tf, workingDir, envVars, ref output); monitor.Log.WriteLine (output); BuildResult result = ParseOutput (tf, output); if (result.Errors.Count == 0 && exitCode != 0) { // Compilation failed, but no errors? // Show everything the compiler said. result.AddError (output); } FileService.DeleteFile (responseFileName); if (configuration.CompileTarget != CompileTarget.Library) { WriteManifestFile (exe); } return result; }
static BuildResult BuildError (string error) { var br = new BuildResult (); br.AddError (error); return br; }
public static BuildResult CreateMergedPlist (IProgressMonitor monitor, ProjectFile template, string outPath, Func<PlistDocument,BuildResult> merge) { var result = new BuildResult (); var doc = new PlistDocument (); if (template != null) { try { doc.LoadFromXmlFile (template.FilePath); } catch (Exception ex) { if (ex is XmlException) result.AddError (template.FilePath, ((XmlException)ex).LineNumber, ((XmlException)ex).LinePosition, null, ex.Message); else result.AddError (template.FilePath, 0, 0, null, ex.Message); monitor.ReportError (GettextCatalog.GetString ("Could not load file '{0}': {1}", template.FilePath, ex.Message), null); return result; } } try { if (result.Append (merge (doc)).ErrorCount > 0) return result; } catch (Exception ex) { result.AddError ("Error merging Info.plist: " + ex.Message); LoggingService.LogError ("Error merging Info.plist", ex); return result; } try { EnsureDirectoryForFile (outPath); doc.WriteToFile (outPath); } catch (Exception ex) { result.AddError (outPath, 0, 0, null, ex.Message); monitor.ReportError (GettextCatalog.GetString ("Could not write file '{0}'", outPath), ex); } return result; }
// 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; } } }
public static BuildResult GenerateCodeBehind ( DotNetProject project, string filename, WebFormsParsedDocument document, out CodeCompileUnit ccu) { ccu = null; var result = new BuildResult (); string className = document.Info.InheritedClass; AddErrorsToResult (result, filename, document.GetErrorsAsync().Result); if (result.ErrorCount > 0) return result; if (string.IsNullOrEmpty (className)) return result; var refman = new WebFormsTypeContext { Project = project, Doc = document }; refman.CreateCompilation (default(CancellationToken)).Wait (); var memberList = new WebFormsMemberListBuilder (refman, document.XDocument); memberList.Build (); AddErrorsToResult (result, filename, memberList.Errors); if (result.ErrorCount > 0) return result; //initialise the generated type ccu = new CodeCompileUnit (); var namespac = new CodeNamespace (); ccu.Namespaces.Add (namespac); var typeDecl = new CodeTypeDeclaration { IsClass = true, IsPartial = true, }; namespac.Types.Add (typeDecl); //name the class and namespace int namespaceSplit = className.LastIndexOf ('.'); if (namespaceSplit > -1) { namespac.Name = project.StripImplicitNamespace (className.Substring (0, namespaceSplit)); typeDecl.Name = className.Substring (namespaceSplit + 1); } else { typeDecl.Name = className; } string masterTypeName = null; if (!String.IsNullOrEmpty (document.Info.MasterPageTypeName)) { masterTypeName = document.Info.MasterPageTypeName; } else if (!String.IsNullOrEmpty (document.Info.MasterPageTypeVPath)) { try { var ext = project.GetService<AspNetAppProjectFlavor> (); ProjectFile resolvedMaster = ext.ResolveVirtualPath (document.Info.MasterPageTypeVPath, document.FileName); WebFormsParsedDocument masterParsedDocument = null; if (resolvedMaster != null) masterParsedDocument = TypeSystemService.ParseFile (project, resolvedMaster.FilePath).Result as WebFormsParsedDocument; if (masterParsedDocument != null && !String.IsNullOrEmpty (masterParsedDocument.Info.InheritedClass)) masterTypeName = masterParsedDocument.Info.InheritedClass; } catch (Exception ex) { LoggingService.LogWarning ("Error resolving master page type", ex); } if (string.IsNullOrEmpty (masterTypeName)) { var msg = string.Format ("Could not find type for master '{0}'", document.Info.MasterPageTypeVPath); result.AddError (filename, msg); return result; } } if (masterTypeName != null) { var masterProp = new CodeMemberProperty { Name = "Master", Type = new CodeTypeReference (masterTypeName), HasGet = true, HasSet = false, Attributes = MemberAttributes.Public | MemberAttributes.New | MemberAttributes.Final, }; masterProp.GetStatements.Add (new CodeMethodReturnStatement ( new CodeCastExpression (masterTypeName, new CodePropertyReferenceExpression ( new CodeBaseReferenceExpression (), "Master")))); typeDecl.Members.Add (masterProp); } //shortcut building the existing members type map if (memberList.Members.Count == 0) return result; var cls = refman.GetTypeByMetadataName (className); var members = GetDesignerMembers (memberList.Members.Values, cls, filename); //add fields for each control in the page foreach (var member in members) { var type = new CodeTypeReference (member.Type.ToDisplayString (SymbolDisplayFormat.CSharpErrorMessageFormat)); typeDecl.Members.Add (new CodeMemberField (type, member.Name) { Attributes = MemberAttributes.Family }); } return result; }
public static BuildResult UpdateCodeBehind (IProgressMonitor monitor, XibCodeBehind generator, IEnumerable<ProjectFile> items) { var result = new BuildResult (); var writer = MonoDevelop.DesignerSupport.CodeBehindWriter.CreateForProject (monitor, generator.Project); if (!writer.SupportsPartialTypes) { monitor.ReportWarning ("Cannot generate designer code, because CodeDom " + "provider does not support partial classes."); return result; } var files = generator.GetDesignerFilesNeedBuilding (items, false).ToList (); if (files.Count == 0) return result; monitor.BeginTask (GettextCatalog.GetString ("Updating CodeBehind files"), 0); foreach (var f in files) { try { generator.GenerateDesignerCode (writer, f.Key, f.Value); var relPath = f.Value.FilePath.ToRelative (generator.Project.BaseDirectory); monitor.Log.WriteLine (GettextCatalog.GetString ("Updated {0}", relPath)); } catch (Exception ex) { result = result ?? new BuildResult (); result.AddError (f.Key.FilePath, 0, 0, null, ex.Message); LoggingService.LogError (String.Format ("Error generating code for xib file '{0}'", f.Key.FilePath), ex); } } writer.WriteOpenFiles (); monitor.EndTask (); return result; }
public override BuildResult Compile ( Project project, ProjectFileCollection projectFiles, ProjectPackageCollection packages, CProjectConfiguration configuration, IProgressMonitor monitor) { if (!appsChecked) { appsChecked = true; compilerFound = CheckApp (compilerCommand); linkerFound = CheckApp (linkerCommand); } if (!compilerFound) { BuildResult cres = new BuildResult (); cres.AddError ("Compiler not found: " + compilerCommand); return cres; } if (!linkerFound) { BuildResult cres = new BuildResult (); cres.AddError ("Linker not found: " + linkerCommand); return cres; } CompilerResults cr = new CompilerResults (new TempFileCollection ()); bool success = true; string compilerArgs = GetCompilerFlags (project, configuration) + " " + GeneratePkgCompilerArgs (packages); string outputName = Path.Combine (configuration.OutputDirectory, configuration.CompiledOutputName); // Precompile header files and place them in .prec/<config_name>/ if (configuration.PrecompileHeaders) { string precDir = Path.Combine (configuration.SourceDirectory, ".prec"); string precConfigDir = Path.Combine (precDir, configuration.Id); if (!Directory.Exists (precDir)) Directory.CreateDirectory (precDir); if (!Directory.Exists (precConfigDir)) Directory.CreateDirectory (precConfigDir); if (!PrecompileHeaders (projectFiles, configuration, compilerArgs, monitor, cr)) success = false; } else { //old headers could interfere with the build CleanPrecompiledHeaders (configuration); } //compile source to object files monitor.BeginTask (GettextCatalog.GetString ("Compiling source to object files"), 1); foreach (ProjectFile f in projectFiles) { if (!success) break; if (f.Subtype == Subtype.Directory || f.BuildAction != BuildAction.Compile || CProject.IsHeaderFile (f.FilePath)) continue; if (configuration.UseCcache || NeedsCompiling (f, configuration)) success = DoCompilation (f, configuration, compilerArgs, monitor, cr, configuration.UseCcache); } if (success) monitor.Step (1); monitor.EndTask (); if (success) { switch (configuration.CompileTarget) { case CBinding.CompileTarget.Bin: MakeBin (project, projectFiles, configuration, packages, cr, monitor, outputName); break; case CBinding.CompileTarget.StaticLibrary: MakeStaticLibrary (project, projectFiles, configuration, packages, cr, monitor, outputName); break; case CBinding.CompileTarget.SharedLibrary: MakeSharedLibrary (project, projectFiles, configuration, packages, cr, monitor, outputName); break; } } return new BuildResult (cr, ""); }
public static ProcessStartInfo GetTool (string tool, DotNetProject project, IProgressMonitor monitor, out BuildResult error) { var toolPath = project.TargetRuntime.GetToolPath (project.TargetFramework, tool); if (String.IsNullOrEmpty (toolPath)) { var err = GettextCatalog.GetString ("Error: Unable to find '" + tool + "' tool."); monitor.ReportError (err, null); error = new BuildResult (); error.AddError (null, 0, 0, null, err); return null; } error = null; return new ProcessStartInfo (toolPath) { UseShellExecute = false, RedirectStandardError = true, RedirectStandardOutput = true, }; }
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.Add ("--errors", "--warnings", "--notices", "--output-format", "human-readable-text"); args.AddQuoted (file.Input); args.Add ("--compile"); args.AddQuoted (file.Output); var ibtoolPath = AppleSdkSettings.DeveloperRoot.Combine ("usr", "bin", "ibtool"); var psi = new ProcessStartInfo (ibtoolPath, args.ToString ()); monitor.Log.WriteLine (psi.FileName + " " + psi.Arguments); int code; try { code = MacBuildUtilities.ExecuteBuildCommand (monitor, psi); } 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 (monitor.IsCancelRequested) return result; if (code != 0) { result.AddError (null, 0, 0, null, "ibtool returned error code " + code); return result; } } monitor.EndTask (); } return result; }
static BuildResult ParseOutput(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 (); 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; }
internal protected override BuildResult OnRunTarget (IProgressMonitor monitor, string target, ConfigurationSelector configuration) { if (!TargetRuntime.IsInstalled (TargetFramework)) { BuildResult res = new BuildResult (); res.AddError (GettextCatalog.GetString ("Framework '{0}' not installed.", TargetFramework.Name)); return res; } return base.OnRunTarget (monitor, target, configuration); }
protected override BuildResult OnBuild (IProgressMonitor monitor, ConfigurationSelector configuration) { var r = new BuildResult (); r.AddError ("Project unavailable"); return r; }
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; }
BuildResult CreateDnxRuntimeErrorBuildResult() { var buildResult = new BuildResult (); buildResult.AddError (DnxServices.ProjectService.CurrentRuntimeError); return 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); } } }
static void AddErrorsToResult (BuildResult result, string filename, IEnumerable<Error> errors) { foreach (var err in errors) { if (err.ErrorType == ErrorType.Warning) result.AddWarning (filename, err.Region.BeginLine, err.Region.BeginColumn, null, err.Message); else result.AddError (filename, err.Region.BeginLine, err.Region.BeginColumn, null, err.Message); } }