Inheritance: HierarchyNode, IVsGetCfgProvider, IVsProject3, IVsAggregatableProject, IVsProjectFlavorCfgProvider, IPersistFileFormat, IVsProjectBuildSystem, IVsBuildPropertyStorage, IVsComponentUser, IVsDependencyProvider, IVsSccProject2, IBuildDependencyUpdate, IProjectEventsListener, IProjectEventsProvider, IReferenceContainerProvider, IVsProjectSpecialFiles, IVsProjectUpgrade, IVsDesignTimeAssemblyResolution, IVsSetTargetFrameworkWorkerCallback
示例#1
0
        public ProjectConfig(ProjectNode project, string configuration)
        {
            ProjectMgr = project;
            ConfigName = configuration;

            // Because the project can be aggregated by a flavor, we need to make sure
            // we get the outer most implementation of that interface (hence: project --> IUnknown --> Interface)
            var projectUnknown = Marshal.GetIUnknownForObject(ProjectMgr);
            try
            {
                var flavorCfgProvider =
                    (IVsProjectFlavorCfgProvider)
                        Marshal.GetTypedObjectForIUnknown(projectUnknown, typeof (IVsProjectFlavorCfgProvider));
                ErrorHandler.ThrowOnFailure(flavorCfgProvider.CreateProjectFlavorCfg(this, out flavoredCfg));
                if (flavoredCfg == null)
                    throw new COMException();
            }
            finally
            {
                if (projectUnknown != IntPtr.Zero)
                    Marshal.Release(projectUnknown);
            }
            // if the flavored object support XML fragment, initialize it
            var persistXML = flavoredCfg as IPersistXMLFragment;
            if (null != persistXML)
            {
                ProjectMgr.LoadXmlFragment(persistXML, DisplayName);
            }
        }
示例#2
0
        /// <summary>
        ///     Constructor for the FolderNode
        /// </summary>
        /// <param name="root">Root node of the hierarchy</param>
        /// <param name="relativePath">relative path from root i.e.: "NewFolder1\\NewFolder2\\NewFolder3</param>
        /// <param name="element">Associated project element</param>
        public FolderNode(ProjectNode root, string relativePath, ProjectElement element)
            : base(root, element)
        {
            if (relativePath == null)
            {
                throw new ArgumentNullException("relativePath");
            }

            VirtualNodeName = relativePath.TrimEnd('\\');
        }
示例#3
0
        /// <summary>
        ///     Constructor for IVSOutput2 implementation
        /// </summary>
        /// <param name="projectManager">Project 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, ProjectItemInstance outputAssembly)
        {
            if (projectManager == null)
                throw new ArgumentNullException("projectManager");
            if (outputAssembly == null)
                throw new ArgumentNullException("outputAssembly");

            project = projectManager;
            output = outputAssembly;
        }
        public virtual void Initialize(ProjectNode projectNode)
        {
            if (projectNode == null)
            {
                throw new ArgumentNullException("projectNode");
            }

            if (projectNode.CallMSBuild("GetFrameworkPaths") != MSBuildResult.Successful)
            {
                throw new InvalidOperationException("Build of GetFrameworkPaths failed.");
            }

            rarInputs = new RarInputs(projectNode.CurrentConfig);
        }
示例#5
0
        /// <summary>
        ///     Constructor for IVSOutputGroup2 implementation
        /// </summary>
        /// <param name="outputName">
        ///     Name of the output group. See VS_OUTPUTGROUP_CNAME_Build in vsshell.idl for the list of
        ///     standard values
        /// </param>
        /// <param name="msBuildTargetName">MSBuild target name</param>
        /// <param name="projectManager">Project that produce this output</param>
        /// <param name="configuration">Configuration that produce this output</param>
        public OutputGroup(string outputName, string msBuildTargetName, ProjectNode projectManager,
            ProjectConfig configuration)
        {
            if (outputName == null)
                throw new ArgumentNullException("outputName");
            if (msBuildTargetName == null)
                throw new ArgumentNullException("outputName");
            if (projectManager == null)
                throw new ArgumentNullException("projectManager");
            if (configuration == null)
                throw new ArgumentNullException("configuration");

            name = outputName;
            TargetName = msBuildTargetName;
            Project = projectManager;
            ProjectCfg = configuration;
        }
示例#6
0
 /// <summary>
 ///     Constructor for the FileNode
 /// </summary>
 /// <param name="root">Root of the hierarchy</param>
 /// <param name="e">Associated project element</param>
 public FileNode(ProjectNode root, ProjectElement element)
     : base(root, element)
 {
     if (ProjectMgr.NodeHasDesigner(ItemNode.GetMetadata(ProjectFileConstants.Include)))
     {
         HasDesigner = true;
     }
 }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TeXProjectFileNode"/> class.
 /// </summary>
 /// <param name="root">The project node.</param>
 /// <param name="e">The project element node.</param>
 internal TeXProjectFileNode(ProjectNode root, ProjectElement e)
     : base(root, e)
 {
 }
示例#8
0
        /// <summary>
        ///     Constructor for the AssemblyReferenceNode
        /// </summary>
        public AssemblyReferenceNode(ProjectNode root, string assemblyPath)
            : base(root)
        {
            // Validate the input parameters.
            if (null == root)
            {
                throw new ArgumentNullException("root");
            }
            if (string.IsNullOrEmpty(assemblyPath))
            {
                throw new ArgumentNullException("assemblyPath");
            }

            InitializeFileChangeEvents();

            // The assemblyPath variable can be an actual path on disk or a generic assembly name.
            if (File.Exists(assemblyPath))
            {
                // The assemblyPath parameter is an actual file on disk; try to load it.
                assemblyName = AssemblyName.GetAssemblyName(assemblyPath);
                this.assemblyPath = assemblyPath;

                // We register with listeningto chnages onteh path here. The rest of teh cases will call into resolving the assembly and registration is done there.
                fileChangeListener.ObserveItem(this.assemblyPath);
            }
            else
            {
                // The file does not exist on disk. This can be because the file / path is not
                // correct or because this is not a path, but an assembly name.
                // Try to resolve the reference as an assembly name.
                CreateFromAssemblyName(new AssemblyName(assemblyPath));
            }
        }
示例#9
0
        /// <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");
            }

            ReferencedProjectName = referencedProjectName;

            var indexOfSeparator = projectReference.IndexOf('|');


            var 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)
            {
                var projectGuid = projectReference.Substring(0, indexOfSeparator);
                referencedProjectGuid = new Guid(projectGuid);
                if (indexOfSeparator + 1 < projectReference.Length)
                {
                    var 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.");

            // Did we get just a file or a relative path?
            var uri = new Uri(projectPath);

            var referenceDir = PackageUtilities.GetPathDistance(ProjectMgr.BaseURI.Uri, uri);

            Debug.Assert(!string.IsNullOrEmpty(referenceDir),
                "Can not add a project reference because the input for adding one is invalid.");

            var justTheFileName = Path.GetFileName(fileName);
            referencedProjectRelativePath = Path.Combine(referenceDir, justTheFileName);

            referencedProjectFullPath = Path.Combine(projectPath, justTheFileName);

            buildDependency = new BuildDependency(ProjectMgr, referencedProjectGuid);
        }
示例#10
0
 internal TrackDocumentsHelper(ProjectNode project)
 {
     projectMgr = project;
 }
示例#11
0
        public ComReferenceNode(ProjectNode root, VSCOMPONENTSELECTORDATA selectorData, string wrapperTool = null)
            : base(root)
        {
            if (root == null)
            {
                throw new ArgumentNullException("root");
            }
            if (selectorData.type == VSCOMPONENTTYPE.VSCOMPONENTTYPE_Project
                || selectorData.type == VSCOMPONENTTYPE.VSCOMPONENTTYPE_ComPlus)
            {
                throw new ArgumentException(
                    "SelectorData cannot be of type VSCOMPONENTTYPE.VSCOMPONENTTYPE_Project or VSCOMPONENTTYPE.VSCOMPONENTTYPE_ComPlus",
                    "selectorData");
            }

            // Initialize private state
            typeName = selectorData.bstrTitle;
            typeGuid = selectorData.guidTypeLibrary;
            majorVersionNumber = selectorData.wTypeLibraryMajorVersion.ToString(CultureInfo.InvariantCulture);
            minorVersionNumber = selectorData.wTypeLibraryMinorVersion.ToString(CultureInfo.InvariantCulture);
            LCID = selectorData.lcidTypeLibrary.ToString(CultureInfo.InvariantCulture);
            WrapperTool = wrapperTool;

            // Check to see if the COM object actually exists.
            SetInstalledFilePath();
            // If the value cannot be set throw.
            if (string.IsNullOrEmpty(InstalledFilePath))
            {
                throw new InvalidOperationException();
            }
        }
示例#12
0
 /// <summary>
 ///     Overloadde ctor.
 /// </summary>
 /// <param name="ProjectNode">The associated project</param>
 internal SingleFileGenerator(ProjectNode projectMgr)
 {
     this.projectMgr = projectMgr;
 }
示例#13
0
 public ConfigProvider(ProjectNode manager)
 {
     ProjectMgr = manager;
 }
示例#14
0
        public string GetFileNamespace(string fileFullPath, ProjectNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            // Get base namespace from the project
            var namespce = node.GetProjectProperty("RootNamespace");
            if (string.IsNullOrEmpty(namespce))
                namespce = Path.GetFileNameWithoutExtension(fileFullPath);
            ;

            // If the item is added to a subfolder, the name space should reflect this.
            // This is done so that class names from 2 files with the same name but different
            // directories don't conflict.
            var relativePath = Path.GetDirectoryName(fileFullPath);
            var projectPath = Path.GetDirectoryName(node.GetMkDocument());
            // Our project system only support adding files that are sibling of the project file or that are in subdirectories.
            if (string.Compare(projectPath, 0, relativePath, 0, projectPath.Length, true, CultureInfo.CurrentCulture) ==
                0)
            {
                relativePath = relativePath.Substring(projectPath.Length);
            }
            else
            {
                Debug.Fail("Adding an item to the project that is NOT under the project folder.");
                // We are going to use the full file path for generating the namespace
            }

            // Get the list of parts
            var index = 0;
            string[] pathParts;
            pathParts = relativePath.Split(Path.DirectorySeparatorChar);

            // Use a string builder with default size being the expected size
            var result = new StringBuilder(namespce, namespce.Length + relativePath.Length + 1);
            // For each path part
            while (index < pathParts.Length)
            {
                var part = pathParts[index];
                ++index;

                // This could happen if the path had leading/trailing slash, we want to ignore empty pieces
                if (string.IsNullOrEmpty(part))
                    continue;

                // If we reach here, we will be adding something, so add a namespace separator '.'
                result.Append('.');

                // Make sure it starts with a letter
                if (!char.IsLetter(part, 0))
                    result.Append('N');

                // Filter invalid namespace characters
                foreach (var c in part)
                {
                    if (char.IsLetterOrDigit(c))
                        result.Append(c);
                }
            }
            return result.ToString();
        }
示例#15
0
 public ReferenceContainerNode(ProjectNode root)
     : base(root)
 {
     VirtualNodeName = ReferencesNodeVirtualName;
     ExcludeNodeFromScc = true;
 }
示例#16
0
 /// <summary>
 ///     constructor for the ReferenceNode
 /// </summary>
 protected ReferenceNode(ProjectNode root)
     : base(root)
 {
     ExcludeNodeFromScc = true;
 }
示例#17
0
 /// <summary>
 ///     constructor for the ReferenceNode
 /// </summary>
 protected ReferenceNode(ProjectNode root, ProjectElement element)
     : base(root, element)
 {
     ExcludeNodeFromScc = true;
 }
示例#18
0
 /// <summary>
 ///     Constructor for the DependentFileNode
 /// </summary>
 /// <param name="root">Root of the hierarchy</param>
 /// <param name="e">Associated project element</param>
 public DependentFileNode(ProjectNode root, ProjectElement element)
     : base(root, element)
 {
     HasParentNodeNameRelation = false;
 }
 public ProjectDesignerDocumentManager(ProjectNode node)
     : base(node)
 {
 }
示例#20
0
 protected virtual OutputGroup CreateOutputGroup(ProjectNode project, KeyValuePair<string, string> group)
 {
     var outputGroup = new OutputGroup(group.Key, group.Value, project, this);
     return outputGroup;
 }
示例#21
0
 public NestedProjectNode(ProjectNode root, ProjectElement element)
     : base(root, element)
 {
     IsExpanded = true;
 }
示例#22
0
        /// <summary>
        ///     Constructor for the ComReferenceNode.
        /// </summary>
        public ComReferenceNode(ProjectNode root, ProjectElement element)
            : base(root, element)
        {
            typeName = ItemNode.GetMetadata(ProjectFileConstants.Include);
            var typeGuidAsString = ItemNode.GetMetadata(ProjectFileConstants.Guid);
            if (typeGuidAsString != null)
            {
                typeGuid = new Guid(typeGuidAsString);
            }

            majorVersionNumber = ItemNode.GetMetadata(ProjectFileConstants.VersionMajor);
            minorVersionNumber = ItemNode.GetMetadata(ProjectFileConstants.VersionMinor);
            LCID = ItemNode.GetMetadata(ProjectFileConstants.Lcid);
            SetProjectItemsThatRelyOnReferencesToBeResolved(false);
            SetInstalledFilePath();
        }
示例#23
0
        /// <summary>
        ///     Constructor to create a new MSBuild.ProjectItem and add it to the project
        ///     Only have internal constructors as the only one who should be creating
        ///     such object is the project itself (see Project.CreateFileNode()).
        /// </summary>
        internal ProjectElement(ProjectNode project, string itemPath, string itemType)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (string.IsNullOrEmpty(itemPath))
            {
                throw new ArgumentException(
                    SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "itemPath");
            }


            if (string.IsNullOrEmpty(itemType))
            {
                throw new ArgumentException(
                    SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "itemType");
            }

            itemProject = project;

            // create and add the item to the project

            Item = project.BuildProject.AddItem(itemType, MSBuild.ProjectCollection.Escape(itemPath))[0];
            itemProject.SetProjectFileDirty(true);
            RefreshProperties();
        }
示例#24
0
 public BuildDependency(ProjectNode projectMgr, Guid projectReference)
 {
     referencedProjectGuid = projectReference;
     this.projectMgr = projectMgr;
 }
示例#25
0
        /// <summary>
        ///     Constructor to Wrap an existing MSBuild.ProjectItem
        ///     Only have internal constructors as the only one who should be creating
        ///     such object is the project itself (see Project.CreateFileNode()).
        /// </summary>
        /// <param name="project">Project that owns this item</param>
        /// <param name="existingItem">an MSBuild.ProjectItem; can be null if virtualFolder is true</param>
        /// <param name="virtualFolder">Is this item virtual (such as reference folder)</param>
        internal ProjectElement(ProjectNode project, MSBuild.ProjectItem existingItem, bool virtualFolder)
        {
            if (project == null)
                throw new ArgumentNullException("project");
            if (!virtualFolder && existingItem == null)
                throw new ArgumentNullException("existingItem");

            // Keep a reference to project and item
            itemProject = project;
            Item = existingItem;
            IsVirtual = virtualFolder;

            if (IsVirtual)
                virtualProperties = new Dictionary<string, string>();
        }
示例#26
0
        public ProjectReferenceNode(ProjectNode root, ProjectElement element)
            : base(root, element)
        {
            referencedProjectRelativePath = ItemNode.GetMetadata(ProjectFileConstants.Include);
            Debug.Assert(!string.IsNullOrEmpty(referencedProjectRelativePath),
                "Could not retrive referenced project path form project file");

            var guidString = ItemNode.GetMetadata(ProjectFileConstants.Project);

            // Continue even if project setttings cannot be read.
            try
            {
                referencedProjectGuid = new Guid(guidString);

                buildDependency = new BuildDependency(ProjectMgr, referencedProjectGuid);
                ProjectMgr.AddBuildDependency(buildDependency);
            }
            finally
            {
                Debug.Assert(referencedProjectGuid != Guid.Empty,
                    "Could not retrive referenced project guidproject file");

                ReferencedProjectName = ItemNode.GetMetadata(ProjectFileConstants.Name);

                Debug.Assert(!string.IsNullOrEmpty(ReferencedProjectName),
                    "Could not retrive referenced project name form project file");
            }

            var uri = new Uri(ProjectMgr.BaseURI.Uri, referencedProjectRelativePath);

            if (uri != null)
            {
                referencedProjectFullPath = Microsoft.VisualStudio.Shell.Url.Unescape(uri.LocalPath, true);
            }
        }
示例#27
0
 /// <summary>
 ///     Calling this method remove this item from the project file.
 ///     Once the item is delete, you should not longer be using it.
 ///     Note that the item should be removed from the hierarchy prior to this call.
 /// </summary>
 public void RemoveFromProjectFile()
 {
     if (!deleted && Item != null)
     {
         deleted = true;
         itemProject.BuildProject.RemoveItem(Item);
     }
     itemProject = null;
     Item = null;
 }
示例#28
0
 public ProjectNodeProperties(ProjectNode node)
     : base(node)
 {
 }
示例#29
0
        /// <summary>
        ///     Constructor for the ReferenceNode
        /// </summary>
        public AssemblyReferenceNode(ProjectNode root, ProjectElement element)
            : base(root, element)
        {
            GetPathNameFromProjectFile();

            InitializeFileChangeEvents();

            var include = ItemNode.GetMetadata(ProjectFileConstants.Include);

            CreateFromAssemblyName(new AssemblyName(include));
        }