private static void PrintTargetInfo(MBEX.ProjectTargetInstance target, int indentCount) { var indent = indentCount > 1 ? new StringBuilder().Insert(0, "| ", indentCount - 1).ToString() : ""; var tree = indentCount > 0 ? "| " : ""; var targetColor = indentCount > 0 ? (target.Name.StartsWith("_") ? ConsoleColor.DarkGreen : ConsoleColor.Green) : ConsoleColor.Cyan; Utils.WriteColor(indent + tree, ConsoleColor.White); Utils.WriteLineColor(target.Name, targetColor); }
/// <summary> /// Constructor for IVSOutput2 implementation /// </summary> /// <param name="projectManager">Project that produce this output</param> /// <param name="configuration">Configuration that produce this output</param> /// <param name="outputAssembly">MSBuild generated item corresponding to the output assembly (by default, these would be of type MainAssembly</param> public Output(ProjectNode projectManager, MSBuildExecution.ProjectItemInstance outputAssembly) { if (projectManager == null) throw new ArgumentNullException("projectManager"); if (outputAssembly == null) throw new ArgumentNullException("outputAssembly"); project = projectManager; output = outputAssembly; }
private void Trace(MBEX.ProjectTargetInstance target, int traceLevel = 0) { if (target == null) { return; } PrintTargetInfo(target, traceLevel); if (!string.IsNullOrWhiteSpace(target.DependsOnTargets)) { foreach (var dependency in target.Dependencies(project)) { Trace(dependency, traceLevel + 1); } } }
private string GetOutputPath(MSBuildExecution.ProjectInstance properties) { this.currentConfig = properties; string outputPath = GetProjectProperty("OutputPath"); if (!String.IsNullOrEmpty(outputPath)) { outputPath = outputPath.Replace('/', Path.DirectorySeparatorChar); if (outputPath[outputPath.Length - 1] != Path.DirectorySeparatorChar) outputPath += Path.DirectorySeparatorChar; } return outputPath; }
private bool GetBoolAttr(MSBuildExecution.ProjectInstance properties, string name) { this.currentConfig = properties; string s = GetProjectProperty(name); return (s != null && s.ToUpperInvariant().Trim() == "TRUE"); }
private string GetAssemblyName(MSBuildExecution.ProjectInstance properties) { this.currentConfig = properties; string name = null; name = GetProjectProperty(ProjectFileConstants.AssemblyName); if (name == null) name = this.Caption; string outputtype = GetProjectProperty(ProjectFileConstants.OutputType, false); if (outputtype == "library") { outputtype = outputtype.ToLowerInvariant(); name += ".dll"; } else { name += ".exe"; } return name; }
public static string GetMetadataValue(MSBuildExecution.ProjectItemInstance item, string name) { return item.GetMetadataValue(name); }
public static string GetEvaluatedInclude(MSBuildExecution.ProjectItemInstance item) { return item.EvaluatedInclude; }
protected virtual string GetAssemblyFileName(MSBuildExecution.ProjectInstance properties) { this.currentConfig = properties; string name = null; ProjectPropertyInstance property = GetMsBuildProperty(properties, ProjectFileConstants.IntermediateAssembly); name = property != null ? property.EvaluatedValue : null; if (!string.IsNullOrWhiteSpace(name)) return Path.GetFileName(name); property = GetMsBuildProperty(properties, ProjectFileConstants.AssemblyName); name = property != null ? property.EvaluatedValue : null; if (name == null) name = this.Caption; string outputtype = GetProjectProperty(ProjectFileConstants.OutputType, _PersistStorageType.PST_PROJECT_FILE, false); if (outputtype == "library") { outputtype = outputtype.ToLowerInvariant(); name += ".dll"; } else { name += ".exe"; } return name; }
protected static string GetOutputPath(MSBuildExecution.ProjectInstance properties) { ProjectPropertyInstance property = GetMsBuildProperty(properties, "OutputPath"); string outputPath = property != null ? property.EvaluatedValue : null; if (!String.IsNullOrEmpty(outputPath)) { outputPath = outputPath.Replace('/', Path.DirectorySeparatorChar); if (outputPath[outputPath.Length - 1] != Path.DirectorySeparatorChar) outputPath += Path.DirectorySeparatorChar; } return outputPath; }
protected static bool GetBoolAttr(MSBuildExecution.ProjectInstance properties, string name) { ProjectPropertyInstance property = GetMsBuildProperty(properties, name); string stringValue = property != null ? property.EvaluatedValue : null; return string.Equals("true", stringValue, StringComparison.OrdinalIgnoreCase); }
public static IEnumerable<MSBuildExecution.ProjectItemInstance> GetItems(MSBuildExecution.ProjectInstance instance, string name) { MethodInfo getItems = instance.GetType().GetMethod("GetItems", new Type[] { typeof(string) }); return (IEnumerable<MSBuildExecution.ProjectItemInstance>)getItems.Invoke(instance, new object[] { name }); }
/// <summary> /// Lets Visual Studio know that we're done with our design-time build so others can use the build manager. /// </summary> /// <param name="submission">The build submission that built, if any.</param> /// <param name="designTime">This must be the same value as the one passed to <see cref="TryBeginBuild" />.</param> /// <param name="requiresUIThread">This must be the same value as the one passed to <see cref="TryBeginBuild" />.</param> /// <remarks> /// This method must be called on the UI thread. /// </remarks> private void EndBuild(MSBuildExecution.BuildSubmission submission, bool designTime, bool requiresUIThread = false) { IVsBuildManagerAccessor accessor = null; if (Site != null) { accessor = Site.GetService(typeof (SVsBuildManagerAccessor)) as IVsBuildManagerAccessor; } if (accessor != null) { // It's very important that we try executing all three end-build steps, even if errors occur partway through. try { if (submission != null) { Marshal.ThrowExceptionForHR(accessor.UnregisterLoggers(submission.SubmissionId)); } } catch (Exception ex) { if (ErrorHandler.IsCriticalException(ex)) { throw; } Trace.TraceError(ex.ToString()); } try { if (designTime) { Marshal.ThrowExceptionForHR(accessor.EndDesignTimeBuild()); } } catch (Exception ex) { if (ErrorHandler.IsCriticalException(ex)) { throw; } Trace.TraceError(ex.ToString()); } try { if (requiresUIThread) { Marshal.ThrowExceptionForHR(accessor.ReleaseUIThreadForBuild()); } } catch (Exception ex) { if (ErrorHandler.IsCriticalException(ex)) { throw; } Trace.TraceError(ex.ToString()); } } else { MSBuildExecution.BuildManager.DefaultBuildManager.EndBuild(); } BuildInProgress = false; }