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 static BuildResult UpdateDesignerFile( CodeBehindWriter writer, AspNetAppProject project, ProjectFile file, ProjectFile designerFile ) { var result = new BuildResult(); //parse the ASP.NET file var parsedDocument = TypeSystemService.ParseFile(project, file.FilePath) as AspNetParsedDocument; 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); }
private void HandleOptLinkOutput(BuildResult br, string linkerOutput) { var matches = optlinkRegex.Matches(linkerOutput); foreach (Match match in matches) { var error = new BuildError(); // Get associated D source file if (match.Groups ["obj"].Success) { var obj = Project.GetAbsoluteChildPath(new FilePath(match.Groups ["obj"].Value)).ChangeExtension(".d"); foreach (var pf in Project.Files) { if (pf.FilePath == obj) { error.FileName = pf.FilePath; break; } } } error.ErrorText = "Linker error " + match.Groups ["code"].Value + " - " + match.Groups ["message"].Value; br.Append(error); } }
static void ParserOutputFile(NMEProject project, BuildResult result, StringBuilder output, string filename) { StreamReader reader = File.OpenText(filename); string line; while ((line = reader.ReadLine()) != null) { output.AppendLine(line); line = line.Trim(); if (line.Length == 0 || line.StartsWith("\t")) { continue; } BuildError error = CreateErrorFromString(project, line); if (error != null) { result.Append(error); } } reader.Close(); }
/// <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 BuildResult UpdateDesignerFile( CodeBehindWriter writer, DotNetProject project, ProjectFile file, ProjectFile designerFile ) { var result = new BuildResult(); //parse the ASP.NET file if (!(IdeApp.TypeSystemService.ParseFile(project, file.FilePath).Result is WebFormsParsedDocument parsedDocument)) { result.AddError(GettextCatalog.GetString("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); }
BuildResult ParseOutput(TempFileCollection tf, string output) { var result = new BuildResult(output, 1, 0); using (var sr = new StringReader(output)) { while (true) { string curLine = sr.ReadLine(); if (curLine == null) { break; } curLine = curLine.Trim(); if (curLine.Length == 0) { continue; } var error = CreateErrorFromString(curLine); if (error != null) { result.Append(error); } } } return(result); }
public BuildResult GetBuildResult(DnxProject project) { var result = new BuildResult(); result.Append(errorWriter.GetBuildResults(project)); result.SourceTarget = project.Project; return(result); }
public static BuildResult CombineBuildResults(this IBuildTarget target, params BuildResult[] results) { var combinedResult = new BuildResult(); combinedResult.SourceTarget = target; combinedResult.Append(results); return(combinedResult); }
protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem item, ConfigurationSelector configuration) { MoonlightProject proj = item as MoonlightProject; DotNetProjectConfiguration conf = null; if (proj != null) { conf = proj.GetConfiguration(configuration) as DotNetProjectConfiguration; } if (conf == null) { return(base.Build(monitor, item, configuration)); } BuildResult result = base.Build(monitor, item, configuration); if (result.ErrorCount > 0 || monitor.IsCancelRequested) { return(result); } if (proj.GenerateSilverlightManifest) { if (result.Append(GenerateManifest(monitor, proj, conf, configuration)).Failed || monitor.IsCancelRequested) { return(result); } } if (proj.XapOutputs) { if (result.Append(Zip(monitor, proj, conf, configuration)).Failed || monitor.IsCancelRequested) { return(result); } } if (proj.XapOutputs && proj.CreateTestPage) { result.Append(CreateTestPage(monitor, proj, conf)); } return(result); }
public BuildResult GetBuildResults(DnxProject project) { var result = new BuildResult(); result.SourceTarget = project.Project; foreach (var error in parser.GetBuildErrors(project)) { result.Append(error); } return(result); }
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); }
protected override BuildResult OnBuild(IProgressMonitor monitor, ConfigurationSelector configuration) { BuildResult results = new BuildResult("", 1, 0); string outputDirectory = GetOutputDirectory(configuration); if (!string.IsNullOrEmpty(outputDirectory)) { foreach (Translation translation in this.Translations) { if (translation.NeedsBuilding(configuration)) { BuildResult res = translation.Build(monitor, configuration); results.Append(res); } } isDirty = false; } return(results); }
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)); }
/// <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 (!Path.IsPathRooted(error.FileName)) { error.FileName = Project.GetAbsoluteChildPath(error.FileName); } br.Append(error); } } reader.Close(); }
public BuildResult RunTarget(MonoDevelop.Core.IProgressMonitor monitor, string target, ConfigurationSelector configuration) { if (target == ProjectService.BuildTarget) { target = "all"; } else if (target == ProjectService.CleanTarget) { target = "clean"; } DotNetProjectConfiguration conf = (DotNetProjectConfiguration)project.GetConfiguration(configuration); using (var output = new StringWriter()) { using (var tw = new LogTextWriter()) { tw.ChainWriter(output); tw.ChainWriter(monitor.Log); using (ProcessWrapper proc = Runtime.ProcessService.StartProcess("make", "PROFILE=" + conf.Id + " " + target, conf.OutputDirectory, monitor.Log, tw, null)) proc.WaitForOutput(); tw.UnchainWriter(output); tw.UnchainWriter(monitor.Log); var result = new BuildResult(output.ToString(), 1, 0); string[] lines = result.CompilerOutput.Split('\n'); foreach (string line in lines) { var err = CreateErrorFromString(line); if (err != null) { result.Append(err); } } return(result); } } }
public static void HandleLdOutput(AbstractDProject prj, BuildResult br, string linkerOutput) { var ctxt = ResolutionContext.Create(DResolverWrapper.CreateParseCacheView(prj), null, null); ctxt.ContextIndependentOptions = ResolutionOptions.IgnoreAllProtectionAttributes | ResolutionOptions.DontResolveBaseTypes | ResolutionOptions.DontResolveBaseClasses | ResolutionOptions.DontResolveAliases; foreach (Match m in ldErrorRegex.Matches(linkerOutput)) { var error = new BuildError(); var firstSymbolOccurring = ldMangleRegex.Match(m.Groups["err"].Value); if (firstSymbolOccurring.Success) { var mangledString = "_D" + firstSymbolOccurring.Groups["mangle"].Value; var associatedSymbol = DResolver.GetResultMember(Demangler.DemangleAndResolve(mangledString, ctxt)); if (associatedSymbol != null) { error.FileName = (associatedSymbol.NodeRoot as DModule).FileName; error.Line = associatedSymbol.Location.Line; error.Column = associatedSymbol.Location.Column; } } error.ErrorText = m.Groups["msg"].Value; if (string.IsNullOrWhiteSpace(error.ErrorText)) { error.ErrorText = m.Groups["err"].Value; } error.ErrorText = DemangleLdOutput(error.ErrorText); br.Append(error); } }
protected async override Task <BuildResult> OnBuild(ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { var toBuild = Translations.Where(t => t.NeedsBuilding(configuration)).ToArray(); BuildResult results = new BuildResult("", 1, 0); string outputDirectory = GetOutputDirectory(configuration); if (!string.IsNullOrEmpty(outputDirectory)) { await Task.Run(delegate { foreach (Translation translation in toBuild) { if (translation.NeedsBuilding(configuration)) { BuildResult res = translation.Build(monitor, configuration); results.Append(res); } } isDirty = false; }); } return(results); }
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); }
public static void HandleOptLinkOutput(AbstractDProject Project, BuildResult br, string linkerOutput) { var matches = optlinkRegex.Matches(linkerOutput); var ctxt = ResolutionContext.Create(Project == null ? DCompilerService.Instance.GetDefaultCompiler().GenParseCacheView() : Project.ParseCache, null, null); ctxt.ContextIndependentOptions = ResolutionOptions.IgnoreAllProtectionAttributes | ResolutionOptions.DontResolveBaseTypes | ResolutionOptions.DontResolveBaseClasses | ResolutionOptions.DontResolveAliases; foreach (Match match in matches) { var error = new BuildError(); // Get associated D source file if (match.Groups["obj"].Success) { var obj = Project.GetAbsoluteChildPath(new FilePath(match.Groups["obj"].Value)).ChangeExtension(".d"); foreach (var pf in Project.Files) { if (pf.FilePath == obj) { error.FileName = pf.FilePath; break; } } } var msg = match.Groups["message"].Value; var symUndefMatch = symbolUndefRegex.Match(msg); if (symUndefMatch.Success && symUndefMatch.Groups["mangle"].Success) { var mangledSymbol = symUndefMatch.Groups["mangle"].Value; ITypeDeclaration qualifier; try { var resSym = D_Parser.Misc.Mangling.Demangler.DemangleAndResolve(mangledSymbol, ctxt, out qualifier); if (resSym is DSymbol) { var ds = resSym as DSymbol; var ast = ds.Definition.NodeRoot as DModule; if (ast != null) { error.FileName = ast.FileName; } error.Line = ds.Definition.Location.Line; error.Column = ds.Definition.Location.Column; msg = ds.Definition.ToString(false, true); } else { msg = qualifier.ToString(); } } catch (Exception ex) { msg = "<log analysis error> " + ex.Message; } error.ErrorText = msg + " could not be resolved - library reference missing?"; } else { error.ErrorText = "Linker error " + match.Groups["code"].Value + " - " + msg; } br.Append(error); } }
static BuildResult ParseOutput(string stdout, string stderr, ProjectItemCollection projectItems) { var result = new BuildResult(); var compilerOutput = new StringBuilder(); foreach (string s in new [] { stdout, stderr }) { StreamReader sr = File.OpenText(s); while (true) { string curLine = sr.ReadLine(); compilerOutput.AppendLine(curLine); if (curLine == null) { break; } curLine = curLine.Trim(); if (curLine.Length == 0) { continue; } BuildError error = CreateErrorFromString(curLine); if (error != null) { string path = error.FileName; if (path.StartsWith("...", StringComparison.Ordinal)) // F**k whomever made the choice to do this... (Cory Here... Indeed!) { string known = path.Substring(3); ProjectFile found = null; foreach (ProjectFile finfo in projectItems.GetAll <ProjectFile> ()) { if (finfo.Subtype == Subtype.Directory) { continue; } switch (finfo.BuildAction) { case "Compile": if (finfo.Name.EndsWith(known, StringComparison.Ordinal)) { found = finfo; } break; default: continue; } if (found != null) { break; } } if (found != null) { error.FileName = found.Project.GetAbsoluteChildPath(found.FilePath); } } result.Append(error); } } sr.Close(); } result.CompilerOutput = compilerOutput.ToString(); return(result); }