GetFullPathForElement() public method

Return an absolute path for the passed in element. If the element is already an absolute path, it is returned. Otherwise, it is unrelativized using the project directory as the base. Note that any ".." in the paths will be resolved. For non-file system based project, it may make sense to override.
public GetFullPathForElement ( ) : string
return string
Esempio n. 1
0
        protected internal void RunVsTemplateWizard(ProjectElement element, bool silent)
        {
            ProjectElement elementToUse = (element == null) ? this.nestedProjectElement : element;

            if (elementToUse == null)
            {
                throw new ArgumentNullException("element");
            }
            this.nestedProjectElement = elementToUse;

            Automation.OAProject oaProject = GetAutomationObject() as Automation.OAProject;
            if (oaProject == null || oaProject.ProjectItems == null)
            {
                throw new System.InvalidOperationException(SR.GetString(SR.InvalidAutomationObject, CultureInfo.CurrentUICulture));
            }
            Debug.Assert(oaProject.Object != null, "The project automation object should have set the Object to the SolutionFolder");
            Automation.OASolutionFolder <ProjectContainerNode> folder = oaProject.Object as Automation.OASolutionFolder <ProjectContainerNode>;

            // Prepare the parameters to pass to RunWizardFile
            string destination = elementToUse.GetFullPathForElement();
            string template    = this.GetProjectTemplatePath(elementToUse);

            object[] wizParams = new object[7];
            wizParams[0] = EnvDTE.Constants.vsWizardAddSubProject;
            wizParams[1] = Path.GetFileNameWithoutExtension(destination);
            wizParams[2] = oaProject.ProjectItems;
            wizParams[3] = Path.GetDirectoryName(destination);
            wizParams[4] = Path.GetFileNameWithoutExtension(destination);
            wizParams[5] = Path.GetDirectoryName(folder.DTE.FullName);             //VS install dir
            wizParams[6] = silent;

            IVsDetermineWizardTrust wizardTrust = this.GetService(typeof(SVsDetermineWizardTrust)) as IVsDetermineWizardTrust;

            if (wizardTrust != null)
            {
                Guid guidProjectAdding = Guid.Empty;

                // In case of a project template an empty guid should be added as the guid parameter. See env\msenv\core\newtree.h IsTrustedTemplate method definition.
                ErrorHandler.ThrowOnFailure(wizardTrust.OnWizardInitiated(template, ref guidProjectAdding));
            }

            try
            {
                // Make the call to execute the wizard. This should cause AddNestedProjectFromTemplate to be
                // called back with the correct set of parameters.
                EnvDTE.IVsExtensibility extensibilityService = (EnvDTE.IVsExtensibility)GetService(typeof(EnvDTE.IVsExtensibility));
                EnvDTE.wizardResult     result = extensibilityService.RunWizardFile(template, 0, ref wizParams);
                if (result == EnvDTE.wizardResult.wizardResultFailure)
                {
                    throw new COMException();
                }
            }
            finally
            {
                if (wizardTrust != null)
                {
                    ErrorHandler.ThrowOnFailure(wizardTrust.OnWizardCompleted());
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// This will clone a template project file and add it as a
        /// subproject to our hierarchy.
        /// If you want to create a project for which there exist a
        /// vstemplate, consider using RunVsTemplateWizard instead.
        /// </summary>
        protected internal virtual NestedProjectNode AddNestedProjectFromTemplate(ProjectElement element, __VSCREATEPROJFLAGS creationFlags)
        {
            ProjectElement elementToUse = (element == null) ? this.nestedProjectElement : element;

            if (elementToUse == null)
            {
                throw new ArgumentNullException("element");
            }
            string destination = elementToUse.GetFullPathForElement();
            string template    = this.GetProjectTemplatePath(elementToUse);

            return(this.AddNestedProjectFromTemplate(template, Path.GetDirectoryName(destination), Path.GetFileName(destination), elementToUse, creationFlags));
        }
Esempio n. 3
0
        /// <summary>
        /// Add an existing project as a nested node of our hierarchy.
        /// This is used while loading the project and can also be used
        /// to add an existing project to our hierarchy.
        /// </summary>
        protected internal virtual NestedProjectNode AddExistingNestedProject(ProjectElement element, __VSCREATEPROJFLAGS creationFlags)
        {
            ProjectElement elementToUse = (element == null) ? this.nestedProjectElement : element;

            if(elementToUse == null)
            {
                throw new ArgumentNullException("element");
            }

            string filename = elementToUse.GetFullPathForElement();
            // Delegate to AddNestedProjectFromTemplate. Because we pass flags that specify open project rather then clone, this will works.
            Debug.Assert((creationFlags & __VSCREATEPROJFLAGS.CPF_OPENFILE) == __VSCREATEPROJFLAGS.CPF_OPENFILE, "__VSCREATEPROJFLAGS.CPF_OPENFILE should have been specified, did you mean to call AddNestedProjectFromTemplate?");
            return AddNestedProjectFromTemplate(filename, Path.GetDirectoryName(filename), Path.GetFileName(filename), elementToUse, creationFlags);
        }
 /// <summary>
 /// Constructor for the ReferenceNode
 /// </summary>
 public ApplicationReferenceNode(ProjectNode root, ProjectElement element)
     : base(root, element)
 {
     this.path     = element.GetFullPathForElement();
     this.filename = Path.GetFileName(this.path);
 }
 /// <summary>
 /// Constructor for the ReferenceNode
 /// </summary>
 public ApplicationReferenceNode(ProjectNode root, ProjectElement element)
     : base(root, element)
 {
     this.path = element.GetFullPathForElement();
     this.filename = Path.GetFileName(this.path);
 }