/// <summary> /// Constructor for the ReferenceNode. It is called when the project is reloaded, when the project element representing the refernce exists. /// </summary> public ProjectReferenceNode(ProjectNode root, ProjectElement element) : base(root, element) { this.referencedProjectRelativePath = this.ItemNode.GetMetadata(ProjectFileConstants.Include); Debug.Assert(!String.IsNullOrEmpty(this.referencedProjectRelativePath), "Could not retrieve referenced project path form project file"); string guidString = this.ItemNode.GetMetadata(ProjectFileConstants.Project); // Continue even if project setttings cannot be read. try { this.referencedProjectGuid = new Guid(guidString); this.buildDependency = new BuildDependency(this.ProjectMgr, this.referencedProjectGuid); this.ProjectMgr.AddBuildDependency(this.buildDependency); } finally { Debug.Assert(this.referencedProjectGuid != Guid.Empty, "Could not retrive referenced project guidproject file"); this.referencedProjectName = this.ItemNode.GetMetadata(ProjectFileConstants.Name); Debug.Assert(!String.IsNullOrEmpty(this.referencedProjectName), "Could not retrive referenced project name form project file"); } // TODO: Maybe referenced projects should be relative to ProjectDir? this.referencedProjectFullPath = CommonUtils.GetAbsoluteFilePath(this.ProjectMgr.ProjectHome, this.referencedProjectRelativePath); }
public void RunFinished() { if (File.Exists(pathToNewSolution)) { File.Delete(pathToNewSolution); } //if the selected folder exist - we will add the project manually if (selectedFolderName != null) { solution.Open(pathToOldSolution); Project selectedProj = solution.FindProjectInSolution(selectedFolderName); if (selectedProj != null) { SolutionFolder selectedFolder = (SolutionFolder)(selectedProj.Object); foreach (string projPath in newProjectsPathToAdd) { selectedFolder.AddFromFile(projPath); } } } BuildDependency webApiDependencies = solution.SolutionBuild.BuildDependencies.Item(webApiUniqueID); if (webApiDependencies != default) { foreach (string projUniqueID in newProjectsUniqueIds) { webApiDependencies.AddProject(projUniqueID); } } }
/// <summary> /// constructor for the ProjectReferenceNode /// </summary> public ProjectReferenceNode(ProjectNode root, string referencedProjectName, string projectPath, string projectReference) : base(root) { Debug.Assert(root != null && !String.IsNullOrEmpty(referencedProjectName) && !String.IsNullOrEmpty(projectReference) && !String.IsNullOrEmpty(projectPath), "Can not add a reference because the input for adding one is invalid."); if (projectReference == null) { throw new ArgumentNullException("projectReference"); } this.referencedProjectName = referencedProjectName; int indexOfSeparator = projectReference.IndexOf('|'); string fileName = String.Empty; // Unfortunately we cannot use the path part of the projectReference string since it is not resolving correctly relative pathes. if (indexOfSeparator != -1) { string projectGuid = projectReference.Substring(0, indexOfSeparator); this.referencedProjectGuid = new Guid(projectGuid); if (indexOfSeparator + 1 < projectReference.Length) { string remaining = projectReference.Substring(indexOfSeparator + 1); indexOfSeparator = remaining.IndexOf('|'); if (indexOfSeparator == -1) { fileName = remaining; } else { fileName = remaining.Substring(0, indexOfSeparator); } } } Debug.Assert(!String.IsNullOrEmpty(fileName), "Can not add a project reference because the input for adding one is invalid."); string justTheFileName = Path.GetFileName(fileName); this.referencedProjectFullPath = CommonUtils.GetAbsoluteFilePath(projectPath, justTheFileName); // TODO: Maybe referenced projects should be relative to ProjectDir? this.referencedProjectRelativePath = CommonUtils.GetRelativeFilePath(this.ProjectMgr.ProjectHome, this.referencedProjectFullPath); this.buildDependency = new BuildDependency(this.ProjectMgr, this.referencedProjectGuid); }
// This method is called after the project is created. public void RunFinished() { EnvDTE.DTE dte = (EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE"); int projectCount = dte.Solution.Projects.Count; if (projectCount == NUMBER_OF_PROJECTS) { Project adapterLibProject = dte.Solution.Item(ADAPTERLIB_PROJECT_INDEX); Project bridgeRTProject = dte.Solution.Item(BRIDGERT_PROJECT_INDEX); BuildDependency bd = dte.Solution.SolutionBuild.BuildDependencies.Item(adapterLibProject.UniqueName); if (bd != null) { bd.AddProject(bridgeRTProject.UniqueName); } } }
public static List <Project> GetActiveProjects() { //rely on GetSolutionProjects to get the ordered list, List <Project> order = GetSolutionProjects(); List <Project> projects = new List <Project>(); Array AllProjects = opCpp2005.App().ActiveSolutionProjects as Array; foreach (Project p in AllProjects) { if (p.Kind == VcProjGuid) { //now add all the dependencies BuildDependency dep = opCpp2005.App().Solution.SolutionBuild.BuildDependencies.Item(p); if (dep != null) { Array required = dep.RequiredProjects as Array; foreach (Project dp in required) { projects.Add(dp); } } //add the project projects.Add(p); } } //Only want the ordered projects that are in the projects list. order.RemoveAll( delegate(Project p) { bool found = projects.Exists(delegate(Project match) { return(match == p); }); if (found) { return(false); } return(true); } ); return(order); }
public void Attach_dependency_to_the_build_error_but_do_not_create_new_error_for_dependency() { ValidationBuildSession session = validatedSession(r => { r.InstanceOf <IWidget>().IsThis(errorInstance().WithName("BadInstance")); r.InstanceOf <SomethingThatNeedsAWidget>().Is.OfConcreteType <SomethingThatNeedsAWidget>() .WithName("DependentInstance") .CtorDependency <IWidget>().Is(x => x.TheInstanceNamed("BadInstance")); }); BuildError error = getFirstAndOnlyError(session); Assert.AreEqual(1, error.Dependencies.Count); BuildDependency dependency = error.Dependencies[0]; Assert.AreEqual(typeof(SomethingThatNeedsAWidget), dependency.PluginType); Assert.AreEqual("DependentInstance", dependency.Instance.Name); }
public BuildDependencyNodeFactory(BuildDependency dependency) { _dependency = dependency; }
public ShellBuildDependency(BuildDependency dependency) { _dependency = dependency; }
internal static BuildModule FromRuntimeValue(ILogSink logger, IDictionary <string, RuntimeValue> value) { if (!value.ContainsKey("id")) { logger.LogWarning("Build module missing \"id\" field."); } foreach (var key in value.Keys) { if (key != "id" && key != "properties" && key != "artifacts" && key != "dependencies") { logger.LogWarning($"Build module has unknown field \"{key}\"."); } } return(new BuildModule { Id = value["id"].AsString(), Properties = value.ContainsKey("properties") ? value["properties"].AsDictionary().ToDictionary(p => p.Key, p => p.Value.AsString()) : null, Artifacts = value.ContainsKey("artifacts") ? value["artifacts"].AsEnumerable().Select(a => BuildArtifact.FromRuntimeValue(logger, a.AsDictionary())) : null, Dependencies = value.ContainsKey("dependencies") ? value["dependencies"].AsEnumerable().Select(d => BuildDependency.FromRuntimeValue(logger, d.AsDictionary())) : null }); }