/// <summary> /// Constructor for the ReferenceNode. It is called when the project is reloaded, when the project element representing the refernce exists. /// </summary> internal ProjectReferenceNode(ProjectNode root, ProjectElement element) : base(root, element) { this.referencedProjectRelativePath = this.ItemNode.GetMetadata(ProjectFileConstants.Include); Debug.Assert(!String.IsNullOrEmpty(this.referencedProjectRelativePath), "Could not retrive 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"); } Uri uri = new Uri(this.ProjectMgr.BaseURI.Uri, this.referencedProjectRelativePath); if (uri != null) { this.referencedProjectFullPath = Microsoft.VisualStudio.Shell.Url.Unescape(uri.LocalPath, true); } }
/// <summary> /// constructor for the ProjectReferenceNode /// </summary> internal 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."); 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."); if (!System.IO.Path.IsPathRooted(projectPath)) { IVsSolution sln = this.ProjectMgr.Site.GetService(typeof(SVsSolution)) as IVsSolution; string slnDir, slnFile, slnOptsFile; sln.GetSolutionInfo(out slnDir, out slnFile, out slnOptsFile); projectPath = Path.Combine(slnDir, projectPath); } Uri uri = new Uri(projectPath); string referenceDir = Path.GetDirectoryName(PackageUtilities.GetPathDistance(this.ProjectMgr.BaseURI.Uri, uri)); Debug.Assert(!String.IsNullOrEmpty(referenceDir), "Can not add a project reference because the input for adding one is invalid."); string justTheFileName = Path.GetFileName(fileName); this.referencedProjectRelativePath = Path.Combine(referenceDir, justTheFileName); this.referencedProjectFullPath = Path.Combine(Path.GetDirectoryName(projectPath), justTheFileName); this.buildDependency = new BuildDependency(this.ProjectMgr, this.referencedProjectGuid); }
internal 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."); 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."); if (!System.IO.Path.IsPathRooted(projectPath)) { IVsSolution sln = this.ProjectMgr.Site.GetService(typeof(SVsSolution)) as IVsSolution; string slnDir, slnFile, slnOptsFile; sln.GetSolutionInfo(out slnDir, out slnFile, out slnOptsFile); projectPath = Path.Combine(slnDir, projectPath); } Uri uri = new Uri(projectPath); string referenceDir = Path.GetDirectoryName(PackageUtilities.GetPathDistance(this.ProjectMgr.BaseURI.Uri, uri)); Debug.Assert(!String.IsNullOrEmpty(referenceDir), "Can not add a project reference because the input for adding one is invalid."); string justTheFileName = Path.GetFileName(fileName); this.referencedProjectRelativePath = Path.Combine(referenceDir, justTheFileName); this.referencedProjectFullPath = Path.Combine(Path.GetDirectoryName(projectPath), justTheFileName); this.buildDependency = new BuildDependency(this.ProjectMgr, this.referencedProjectGuid); }