/// <summary> /// Initializes a new instance of the <see cref="WixProjectReferenceNode"/> class. /// </summary> /// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param> /// <param name="referencedProjectName">The name of the referenced project.</param> /// <param name="projectPath">The path to the referenced project file.</param> /// <param name="projectReference">Project reference GUID.</param> /// <remarks>Constructor used for new project references.</remarks> public WixProjectReferenceNode(WixProjectNode root, string referencedProjectName, string projectPath, string projectReference) : base(root, referencedProjectName, projectPath, projectReference) { this.setDoNotHarvest = "True"; // do not harvest references by default this.setRefProjectOutputGroups = "Binaries;Content;Satellites"; this.setRefTargetDir = "INSTALLFOLDER"; }
/// <summary> /// Initializes a new instance of the <see cref="WixReferenceNode"/> class. /// </summary> /// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param> /// <param name="referencePath">The path to the wixlib reference file.</param> /// <param name="msBuildElementName">The element name of the reference in an MSBuild file.</param> protected WixReferenceNode(WixProjectNode root, string referencePath, string msBuildElementName) : this(root, new ProjectElement(root, referencePath, msBuildElementName)) { this.ItemNode.Rename(Path.GetFileNameWithoutExtension(referencePath)); this.ItemNode.SetMetadata(ProjectFileConstants.Name, Path.GetFileNameWithoutExtension(referencePath)); this.ItemNode.SetMetadata(ProjectFileConstants.HintPath, referencePath); }
// ========================================================================================= // Constructors // ========================================================================================= /// <summary> /// Initializes a new instance of the <see cref="WixReferenceNode"/> class. /// </summary> /// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param> /// <param name="element">The element that contains MSBuild properties.</param> protected WixReferenceNode(WixProjectNode root, ProjectElement element) : base(root, element) { string includeValue = this.ItemNode.GetMetadata(ProjectFileConstants.Include); bool referenceNameNotPresent = String.IsNullOrEmpty(this.ItemNode.GetMetadata(ProjectFileConstants.Name)); string newReferenceName = includeValue; if (String.IsNullOrEmpty(this.ItemNode.GetMetadata(ProjectFileConstants.HintPath))) { this.ItemNode.SetMetadata(ProjectFileConstants.HintPath, includeValue); } if (includeValue.Contains(Path.DirectorySeparatorChar.ToString())) { this.ItemNode.Rename(Path.GetFileNameWithoutExtension(includeValue)); newReferenceName = Path.GetFileNameWithoutExtension(includeValue); } if (referenceNameNotPresent) { // this will fail if the node was included from a targets file try { this.ItemNode.SetMetadata(ProjectFileConstants.Name, newReferenceName); } catch { } } }
// ========================================================================================= // Constructors // ========================================================================================= /// <summary> /// Initializes a new instance of the <see cref="OAWixProject"/> class. /// </summary> /// <param name="wixProject">The node to which this project belongs.</param> public OAWixProject(WixProjectNode wixProject) : base(wixProject) { if (wixProject != null) { this.properties = new OAProperties(wixProject.NodeProperties); } }
public WixFolderNode(WixProjectNode root, string directoryPath, ProjectElement element, bool isNonMemberItem) : base(root, directoryPath, element) { this.isNonMemberItem = isNonMemberItem; // Folders do not participate in SCC. base.ExcludeNodeFromScc = true; }
private static void AddNonMemberFileItems(WixProjectNode project, IList<string> fileList) { if (fileList == null) { throw new ArgumentNullException("fileList"); } foreach (string fileKey in fileList) { HierarchyNode parentNode = project; string[] pathItems = fileKey.Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }); if (String.Equals(fileKey, project.ProjectFile, StringComparison.OrdinalIgnoreCase)) { continue; } WixFolderNode topFolderNode = null; foreach (string fileOrDir in pathItems) { string childNodeId = Path.Combine(parentNode.VirtualNodeName, fileOrDir); FileInfo fileOrDirInfo = new FileInfo(Path.Combine(project.ProjectFolder, childNodeId)); if ((fileOrDirInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) { break; } HierarchyNode childNode = parentNode.FindChild(childNodeId); if (childNode == null) { if (topFolderNode == null) { topFolderNode = parentNode as WixFolderNode; if (topFolderNode != null && (!topFolderNode.IsNonMemberItem) && topFolderNode.IsExpanded) { topFolderNode = null; } } ProjectElement element = new ProjectElement(project, null, true); element.Rename(childNodeId); element.SetMetadata(ProjectFileConstants.Name, childNodeId); childNode = project.CreateFileNode(element); parentNode.AddChild(childNode); break; } parentNode = childNode; } if (topFolderNode != null) { topFolderNode.CollapseFolder(); } } }
internal static void RemoveNonMemberItems(WixProjectNode project) { IList<HierarchyNode> nodeList = new List<HierarchyNode>(); WixHelperMethods.FindNodes(nodeList, project, WixProjectMembers.IsNodeNonMemberItem, null); for (int index = nodeList.Count - 1; index >= 0; index--) { HierarchyNode parent = nodeList[index].Parent; nodeList[index].OnItemDeleted(); parent.RemoveChild(nodeList[index]); } }
/// <summary> /// Initializes a new instance of the <see cref="WixExtensionReferenceNode"/> class. /// </summary> /// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param> /// <param name="referencePath">The path to the wixlib reference file.</param> public WixExtensionReferenceNode(WixProjectNode root, string referencePath) : base(root, referencePath, WixProjectFileConstants.WixExtension) { referencePath = WixHelperMethods.ReplacePathWithBuildProperty(referencePath, ExtensionDirectoryToken, this.ExtensionDirectory); if (!referencePath.StartsWith(ExtensionDirectoryToken, StringComparison.Ordinal) && null != root) { referencePath = root.GetRelativePath(referencePath); } this.ItemNode.SetMetadata(ProjectFileConstants.HintPath, referencePath); this.InitializeFileChangeEvents(); }
internal static void AddNonMemberItems(WixProjectNode project) { IList<string> files = new List<string>(); IList<string> folders = new List<string>(); // obtain the list of files and folders under the project folder. WixProjectMembers.GetRelativeFileSystemEntries(project.ProjectFolder, null, files, folders); // exclude the items which are the part of the build. WixProjectMembers.ExcludeProjectBuildItems(project, files, folders); WixProjectMembers.AddNonMemberFolderItems(project, folders); WixProjectMembers.AddNonMemberFileItems(project, files); }
/// <summary> /// Excludes the file and folder items from their corresponding maps if they are part of the build. /// </summary> /// <param name="project">The project to modify.</param> /// <param name="fileList">List containing relative files paths.</param> /// <param name="folderList">List containing relative folder paths.</param> private static void ExcludeProjectBuildItems(WixProjectNode project, IList<string> fileList, IList<string> folderList) { BuildItemGroup projectItems = project.BuildProject.EvaluatedItems; if (projectItems == null) { return; // do nothig, just ignore it. } else if (fileList == null && folderList == null) { throw new ArgumentNullException("folderList"); } // we need these maps becuase we need to have both lowercase and actual case path information. // we use lower case paths for case-insesitive search of file entries and actual paths for // creating hierarchy node. if we don't do that, we will end up with duplicate nodes when the // case of path in .wixproj file doesn't match with the actual file path on the disk. IDictionary<string, string> folderMap = null; IDictionary<string, string> fileMap = null; if (folderList != null) { folderMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); foreach (string folder in folderList) { folderMap.Add(folder, folder); } } if (fileList != null) { fileMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); foreach (string file in fileList) { fileMap.Add(file, file); } } foreach (BuildItem buildItem in projectItems) { if (folderMap != null && folderMap.Count > 0 && String.Equals(buildItem.Name, ProjectFileConstants.Folder, StringComparison.OrdinalIgnoreCase)) { string relativePath = buildItem.FinalItemSpec; if (Path.IsPathRooted(relativePath)) // if not the relative path, make it relative { relativePath = WixHelperMethods.GetRelativePath(project.ProjectFolder, relativePath); } if (folderMap.ContainsKey(relativePath)) { folderList.Remove(folderMap[relativePath]); // remove it from the actual list. folderMap.Remove(relativePath); } } else if (fileMap != null && fileMap.Count > 0 && WixProjectMembers.IsWixFileItem(buildItem)) { string relativePath = buildItem.FinalItemSpec; if (Path.IsPathRooted(relativePath)) // if not the relative path, make it relative { relativePath = WixHelperMethods.GetRelativePath(project.ProjectFolder, relativePath); } if (fileMap.ContainsKey(relativePath)) { fileList.Remove(fileMap[relativePath]); // remove it from the actual list. fileMap.Remove(relativePath); } } } }
// ========================================================================================= // Constructors // ========================================================================================= /// <summary> /// Initializes a new instance of the <see cref="WixFolderNode"/> class. /// </summary> /// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param> /// <param name="directoryPath">Root of the hierarchy.</param> /// <param name="element">The element that contains MSBuild properties.</param> public WixFolderNode(WixProjectNode root, string directoryPath, ProjectElement element) : this(root, directoryPath, element, false) { }
/// <summary> /// Creates a new project config instance. /// </summary> /// <param name="project">Parent project node.</param> /// <param name="configName">Configuration name such as "Debug".</param> /// <param name="platformName">Platform name such as "x86".</param> public WixProjectConfig(WixProjectNode project, string configName, string platformName) : base(project, new ConfigCanonicalName(configName, platformName)) { }
// ========================================================================================= // Constructors // ========================================================================================= /// <summary> /// Initializes a new instance of the <see cref="WixFileNode"/> class. /// </summary> /// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param> /// <param name="element">The element that contains MSBuild properties.</param> public WixFileNode(WixProjectNode root, ProjectElement element) : this(root, element, false) { }
// ========================================================================================= // Constructors // ========================================================================================= /// <summary> /// Initializes a new instance of the <see cref="WixReferenceContainerNode"/> class. /// </summary> /// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param> public WixReferenceContainerNode(WixProjectNode root) : base(root) { }
/// <summary> /// Creates a new config provider for WiX projects. /// </summary> /// <param name="project">Parent project node</param> public WixConfigProvider(WixProjectNode project) : base(project) { }
// ========================================================================================= // Constructors // ========================================================================================= /// <summary> /// Initializes a new instance of the <see cref="WixReferenceNode"/> class. /// </summary> /// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param> /// <param name="element">The element that contains MSBuild properties.</param> protected WixReferenceNode(WixProjectNode root, ProjectElement element) : base(root, element) { }
/// <summary> /// Handles command status on source a node. Should be overridden by descendant nodes. /// </summary> /// <param name="node">A HierarchyNode that implements the IProjectSourceNode interface.</param> /// <param name="guidCmdGroup">A unique identifier of the command group. The pguidCmdGroup parameter can be NULL to specify the standard group.</param> /// <param name="cmd">The command to query status for.</param> /// <param name="result">An out parameter specifying the QueryStatusResult of the command.</param> /// <param name="returnCode">If the method succeeds, it returns S_OK. If it fails, it returns an error code.</param> /// <returns>Returns true if the status request is handled, false otherwise.</returns> internal static bool QueryStatusOnProjectSourceNode(HierarchyNode node, Guid guidCmdGroup, uint cmd, ref QueryStatusResult result, out int returnCode) { if (guidCmdGroup == VsMenus.guidStandardCommandSet2K) { IProjectSourceNode sourceNode = node as IProjectSourceNode; switch ((VsCommands2K)cmd) { case VsCommands2K.SHOWALLFILES: { WixProjectNode projectNode = node.ProjectMgr as WixProjectNode; result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; if (projectNode != null && projectNode.ShowAllFilesEnabled) { result |= QueryStatusResult.LATCHED; // it should be displayed as pressed } returnCode = VSConstants.S_OK; return(true); // handled. } case VsCommands2K.INCLUDEINPROJECT: // if it is a non member item node, the we support "Include In Project" command if (sourceNode != null && sourceNode.IsNonMemberItem) { result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; returnCode = VSConstants.S_OK; return(true); // handled. } break; case VsCommands2K.EXCLUDEFROMPROJECT: // if it is a non member item node, then we don't support "Exclude From Project" command if (sourceNode != null && sourceNode.IsNonMemberItem) { returnCode = (int)OleConstants.MSOCMDERR_E_NOTSUPPORTED; return(true); // handled. } break; } } if (VsMenus.guidStandardCommandSet97 == guidCmdGroup) { switch ((VsCommands)cmd) { case VsCommands.AddNewItem: case VsCommands.AddExistingItem: result = QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; returnCode = VSConstants.S_OK; return(true); case VsCommands.SetStartupProject: result = QueryStatusResult.SUPPORTED | QueryStatusResult.INVISIBLE; returnCode = VSConstants.S_OK; return(true); } } // just an arbitrary value, it doesn't matter if method hasn't handled the request returnCode = VSConstants.S_FALSE; // not handled return(false); }
// ========================================================================================= // Constructors // ========================================================================================= /// <summary> /// Initializes a new instance of the <see cref="WixLibraryReferenceNode"/> class. /// </summary> /// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param> /// <param name="element">The element that contains MSBuild properties.</param> public WixLibraryReferenceNode(WixProjectNode root, ProjectElement element) : base(root, element) { }
// ========================================================================================= // Constructors // ========================================================================================= /// <summary> /// Initializes a new instance of the <see cref="WixProjectNodeProperties"/> class. /// </summary> /// <param name="node">The <see cref="WixProjectNode"/> from which the properties are read.</param> public WixProjectNodeProperties(WixProjectNode node) : base(node) { }
// ========================================================================================= // Constructors // ========================================================================================= /// <summary> /// Creates a new project property object. /// </summary> /// <param name="project">Project that owns the property.</param> /// <param name="propertyName">Name of the property.</param> public ProjectProperty(WixProjectNode project, string propertyName) { WixHelperMethods.VerifyNonNullArgument(project, "project"); WixHelperMethods.VerifyNonNullArgument(propertyName, "propertyName"); this.project = project; this.propertyName = propertyName; this.perUser = ProjectProperty.PerUserProperties.Contains(propertyName); this.perConfig = !ProjectProperty.NonPerConfigProperties.Contains(propertyName); this.allowVariables = ProjectProperty.AllowVariablesProperties.Contains(propertyName); this.list = ProjectProperty.ListProperties.Contains(propertyName); this.endOfProjectFile = ProjectProperty.EndOfProjectFileProperties.Contains(propertyName); }
/// <summary> /// Excludes the file and folder items from their corresponding maps if they are part of the build. /// </summary> /// <param name="project">The project to modify.</param> /// <param name="fileList">List containing relative files paths.</param> /// <param name="folderList">List containing relative folder paths.</param> private static void ExcludeProjectBuildItems(WixProjectNode project, IList <string> fileList, IList <string> folderList) { BuildItemGroup projectItems = project.BuildProject.EvaluatedItems; if (projectItems == null) { return; // do nothig, just ignore it. } else if (fileList == null && folderList == null) { throw new ArgumentNullException("folderList"); } // we need these maps becuase we need to have both lowercase and actual case path information. // we use lower case paths for case-insesitive search of file entries and actual paths for // creating hierarchy node. if we don't do that, we will end up with duplicate nodes when the // case of path in .wixproj file doesn't match with the actual file path on the disk. IDictionary <string, string> folderMap = null; IDictionary <string, string> fileMap = null; if (folderList != null) { folderMap = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); foreach (string folder in folderList) { folderMap.Add(folder, folder); } } if (fileList != null) { fileMap = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); foreach (string file in fileList) { fileMap.Add(file, file); } } foreach (BuildItem buildItem in projectItems) { if (folderMap != null && folderMap.Count > 0 && String.Equals(buildItem.Name, ProjectFileConstants.Folder, StringComparison.OrdinalIgnoreCase)) { string relativePath = buildItem.FinalItemSpec; if (Path.IsPathRooted(relativePath)) // if not the relative path, make it relative { relativePath = WixHelperMethods.GetRelativePath(project.ProjectFolder, relativePath); } if (folderMap.ContainsKey(relativePath)) { folderList.Remove(folderMap[relativePath]); // remove it from the actual list. folderMap.Remove(relativePath); } } else if (fileMap != null && fileMap.Count > 0 && WixProjectMembers.IsWixFileItem(buildItem)) { string relativePath = buildItem.FinalItemSpec; if (Path.IsPathRooted(relativePath)) // if not the relative path, make it relative { relativePath = WixHelperMethods.GetRelativePath(project.ProjectFolder, relativePath); } if (fileMap.ContainsKey(relativePath)) { fileList.Remove(fileMap[relativePath]); // remove it from the actual list. fileMap.Remove(relativePath); } } } }
/// <summary> /// Creates a new config provider for WiX projects. /// </summary> /// <param name="project">Parent project node</param> public WixConfigProvider(WixProjectNode project) : base(project) { this.wixProjectNode = project; }
/// <summary> /// Creates a new project config instance. /// </summary> /// <param name="project">Parent project node.</param> /// <param name="configName">Configuration name such as "Debug".</param> /// <param name="platformName">Platform name such as "x86".</param> public WixProjectConfig(WixProjectNode project, string configName, string platformName) : base(project, configName, platformName) { }
public WixFileNode(WixProjectNode root, ProjectElement element, bool isNonMemberItem) : base(root, element) { this.isNonMemberItem = isNonMemberItem; }
/// <summary> /// Initializes a new instance of the <see cref="WixLibraryReferenceNode"/> class. /// </summary> /// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param> /// <param name="referencePath">The path to the wixlib reference file.</param> public WixLibraryReferenceNode(WixProjectNode root, string referencePath) : base(root, referencePath, WixProjectFileConstants.WixLibrary) { }
// ========================================================================================= // Constructors // ========================================================================================= /// <summary> /// Initializes a new instance of the <see cref="WixExtensionReferenceNode"/> class. /// </summary> /// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param> /// <param name="element">The element that contains MSBuild properties.</param> public WixExtensionReferenceNode(WixProjectNode root, ProjectElement element) : base(root, element) { this.InitializeFileChangeEvents(); }
/// <summary> /// Initializes a new instance of the <see cref="WixReferenceNode"/> class. /// </summary> /// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param> /// <param name="referencePath">The path to the wixlib reference file.</param> /// <param name="msBuildElementName">The element name of the reference in an MSBuild file.</param> protected WixReferenceNode(WixProjectNode root, string referencePath, string msBuildElementName) : this(root, new ProjectElement(root, referencePath, msBuildElementName)) { }
int IProjectSourceNode.ExcludeFromProject() { if (this.ProjectMgr == null || this.ProjectMgr.IsClosed) { return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED); } else if (this.IsNonMemberItem) { return(VSConstants.S_OK); // do nothing, just ignore it. } using (WixHelperMethods.NewWaitCursor()) { // Ask Document tracker listeners if we can remove the item. { // just to limit the scope. string documentToRemove = this.GetMkDocument(); string[] filesToBeDeleted = new string[1] { documentToRemove }; VSQUERYREMOVEFILEFLAGS[] queryRemoveFlags = this.GetQueryRemoveFileFlags(filesToBeDeleted); if (!this.ProjectMgr.Tracker.CanRemoveItems(filesToBeDeleted, queryRemoveFlags)) { return((int)OleConstants.OLECMDERR_E_CANCELED); } // Close the document if it has a manager. DocumentManager manager = this.GetDocumentManager(); if (manager != null) { if (manager.Close(__FRAMECLOSE.FRAMECLOSE_PromptSave) == VSConstants.E_ABORT) { // User cancelled operation in message box. return(VSConstants.OLE_E_PROMPTSAVECANCELLED); } } // Check out the project file. if (!this.ProjectMgr.QueryEditProjectFile(false)) { throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); } } // close the document window if open. this.CloseDocumentWindow(this); WixProjectNode projectNode = this.ProjectMgr as WixProjectNode; if (projectNode != null && projectNode.ShowAllFilesEnabled && File.Exists(this.Url)) { // need to store before removing the node. string url = this.Url; string include = this.ItemNode.GetMetadata(ProjectFileConstants.Include); this.ItemNode.RemoveFromProjectFile(); this.ProjectMgr.Tracker.OnItemRemoved(url, VSREMOVEFILEFLAGS.VSREMOVEFILEFLAGS_NoFlags); this.SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, true); // Set it as non member item this.ItemNode = new ProjectElement(this.ProjectMgr, null, true); // now we have to set a new ItemNode to indicate that this is virtual node. this.ItemNode.Rename(include); this.ItemNode.SetMetadata(ProjectFileConstants.Name, url); ////this.ProjectMgr.OnItemAdded(this.Parent, this); this.ReDraw(UIHierarchyElement.Icon); // We have to redraw the icon of the node as it is now not a member of the project and should be drawn using a different icon. this.ReDraw(UIHierarchyElement.SccState); // update the SCC state icon. } else if (this.Parent != null) // the project node has no parentNode { // Remove from the Hierarchy this.OnItemDeleted(); this.Parent.RemoveChild(this); this.ItemNode.RemoveFromProjectFile(); } this.ResetProperties(); // refresh property browser... WixHelperMethods.RefreshPropertyBrowser(); } return(VSConstants.S_OK); }
// ========================================================================================= // Methods // ========================================================================================= /// <summary> /// Hides all of the tabs in the Add Reference dialog except for the browse tab, which will search for wixlibs. /// </summary> /// <param name="project">The project that will contain the reference.</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns> internal static int AddProjectReference(WixProjectNode project) { CCITracing.TraceCall(); Guid showOnlyThisTabGuid = Guid.Empty; Guid startOnThisTabGuid = VSConstants.GUID_BrowseFilePage; string helpTopic = "VS.AddReference"; string machineName = String.Empty; string browseFilters = WixProjectReferenceNode.AddReferenceDialogFilter; string browseLocation = WixProjectReferenceNode.GetAddReferenceDialogInitialDirectory(project.WixPackage); // initialize the structure that we have to pass into the dialog call VSCOMPONENTSELECTORTABINIT[] tabInitializers = new VSCOMPONENTSELECTORTABINIT[2]; // tab 1 is the Project References tab: passing VSHPROPID_ShowProjInSolutionPage will tell the Add Reference // dialog to call into our GetProperty to determine if we should show ourself in the dialog tabInitializers[0].dwSize = (uint)Marshal.SizeOf(typeof(VSCOMPONENTSELECTORTABINIT)); tabInitializers[0].guidTab = VSConstants.GUID_SolutionPage; tabInitializers[0].varTabInitInfo = (int)__VSHPROPID.VSHPROPID_ShowProjInSolutionPage; // tab 2 is the Browse tab tabInitializers[1].dwSize = (uint)Marshal.SizeOf(typeof(VSCOMPONENTSELECTORTABINIT)); tabInitializers[1].guidTab = VSConstants.GUID_BrowseFilePage; tabInitializers[1].varTabInitInfo = 0; // initialize the flags to control the dialog __VSCOMPSELFLAGS flags = __VSCOMPSELFLAGS.VSCOMSEL_HideCOMClassicTab | __VSCOMPSELFLAGS.VSCOMSEL_HideCOMPlusTab | __VSCOMPSELFLAGS.VSCOMSEL_IgnoreMachineName | __VSCOMPSELFLAGS.VSCOMSEL_MultiSelectMode; // get the dialog service from the environment IVsComponentSelectorDlg dialog = WixHelperMethods.GetService<IVsComponentSelectorDlg, SVsComponentSelectorDlg>(project.Site); try { // show the dialog ErrorHandler.ThrowOnFailure(dialog.ComponentSelectorDlg( (uint)flags, (IVsComponentUser)project, WixProjectReferenceNode.AddReferenceDialogTitle, helpTopic, ref showOnlyThisTabGuid, ref startOnThisTabGuid, machineName, (uint)tabInitializers.Length, tabInitializers, browseFilters, ref browseLocation)); } catch (COMException e) { CCITracing.Trace(e); return e.ErrorCode; } return VSConstants.S_OK; }
// ========================================================================================= // Constructors // ========================================================================================= /// <summary> /// Initializes a new instance of the <see cref="WixExtensionReferenceNode"/> class. /// </summary> /// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param> /// <param name="element">The element that contains MSBuild properties.</param> public WixExtensionReferenceNode(WixProjectNode root, ProjectElement element) : base(root, element) { this.ExtractPropertiesFromFile(); }
/// <summary> /// Initializes a new instance of the <see cref="WixExtensionReferenceNode"/> class. /// </summary> /// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param> /// <param name="referencePath">The path to the wixlib reference file.</param> public WixExtensionReferenceNode(WixProjectNode root, string referencePath) : base(root, referencePath, WixProjectFileConstants.WixExtension) { this.ExtractPropertiesFromFile(); }
private static void AddNonMemberFolderItems(WixProjectNode project, IList<string> folderList) { if (folderList == null) { throw new ArgumentNullException("folderList"); } foreach (string folderKey in folderList) { HierarchyNode parentNode = project; string[] folders = folderKey.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); WixFolderNode topFolderNode = null; foreach (string folder in folders) { string childNodeId = Path.Combine(parentNode.VirtualNodeName, folder); FileInfo folderInfo = new FileInfo(Path.Combine(project.ProjectFolder, childNodeId)); if ((folderInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) { break; } HierarchyNode childNode = parentNode.FindChild(childNodeId); if (childNode == null) { if (topFolderNode == null) { topFolderNode = parentNode as WixFolderNode; if (topFolderNode != null && (!topFolderNode.IsNonMemberItem) && topFolderNode.IsExpanded) { topFolderNode = null; } } ProjectElement element = new ProjectElement(project, null, true); childNode = project.CreateFolderNode(childNodeId, element); parentNode.AddChild(childNode); } parentNode = childNode; } if (topFolderNode != null) { topFolderNode.CollapseFolder(); } } }
/// <summary> /// Creates a new <see cref="WixProjectNode"/>. /// </summary> /// <returns>A new <see cref="WixProjectNode"/> object.</returns> protected override ProjectNode CreateProject() { WixProjectNode project = new WixProjectNode(this.Package as WixPackage); project.SetSite((IOleServiceProvider)((IServiceProvider)this.Package).GetService(typeof(IOleServiceProvider))); return project; }
// ========================================================================================= // Constructors // ========================================================================================= /// <summary> /// Initializes a new instance of the <see cref="WixProjectReferenceNode"/> class. /// </summary> /// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param> /// <param name="element">The element that contains MSBuild properties.</param> public WixProjectReferenceNode(WixProjectNode root, ProjectElement element) : base(root, element) { }
int IProjectSourceNode.ExcludeFromProject() { WixProjectNode projectNode = this.ProjectMgr as WixProjectNode; if (projectNode == null || projectNode.IsClosed) { return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED); } else if (this.IsNonMemberItem) { return(VSConstants.S_OK); // do nothing, just ignore it. } using (WixHelperMethods.NewWaitCursor()) { // Check out the project file. if (!projectNode.QueryEditProjectFile(false)) { throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); } // remove children, if any, before removing from the hierarchy for (HierarchyNode child = this.FirstChild; child != null; child = child.NextSibling) { IProjectSourceNode node = child as IProjectSourceNode; if (node != null) { int result = node.ExcludeFromProject(); if (result != VSConstants.S_OK) { return(result); } } } if (projectNode != null && projectNode.ShowAllFilesEnabled && Directory.Exists(this.Url)) { string url = this.Url; this.SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, true); this.ItemNode.RemoveFromProjectFile(); this.ItemNode = new ProjectElement(this.ProjectMgr, null, true); // now we have to create a new ItemNode to indicate that this is virtual node. this.ItemNode.Rename(url); this.ItemNode.SetMetadata(ProjectFileConstants.Name, this.Url); this.ReDraw(UIHierarchyElement.Icon); // we have to redraw the icon of the node as it is now not a member of the project and shoul be drawn using a different icon. } else if (this.Parent != null) // the project node has no parentNode { // this is important to make it non member item. otherwise, the multi-selection scenario would // not work if it has any parent child relation. this.SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, true); // remove from the hierarchy this.OnItemDeleted(); this.Parent.RemoveChild(this); this.ItemNode.RemoveFromProjectFile(); } // refresh property browser... WixHelperMethods.RefreshPropertyBrowser(); } return(VSConstants.S_OK); }
// ========================================================================================= // Constructors // ========================================================================================= /// <summary> /// Initializes a new instance of the <see cref="WixFileNode"/> class. /// </summary> /// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param> /// <param name="element">The element that contains MSBuild properties.</param> public WixFileNode(WixProjectNode root, ProjectElement element) : base(root, element) { }