コード例 #1
0
        /// <summary>
        /// Use the data passed in to initialize the Properties.
        /// </summary>
        /// <param name="dataObject">
        /// This is normally only one our configuration object, which means that
        /// there will be only one elements in configs.
        /// If it is null, we should release it.
        /// </param>
        public void Initialize(object[] dataObjects)
        {
            // If we are editing multiple configuration at once, we may get multiple objects.
            foreach (object dataObject in dataObjects)
            {
                if (dataObject is IVsBrowseObject)
                {
                    // Project properties page
                    IVsBrowseObject browseObject = dataObject as IVsBrowseObject;
                    IVsHierarchy    pHier;
                    uint            pItemid;
                    ErrorHandler.ThrowOnFailure(browseObject.GetProjectItem(out pHier, out pItemid));
                    buildPropStorage = (IVsBuildPropertyStorage)pHier;
                    break;
                }
                else if (dataObject is IVsCfgBrowseObject)
                {
                    // Configuration dependent properties page
                    if (buildPropStorage == null)
                    {
                        IVsCfgBrowseObject browseObject = dataObject as IVsCfgBrowseObject;
                        IVsHierarchy       pHier;
                        uint pItemid;
                        ErrorHandler.ThrowOnFailure(browseObject.GetProjectItem(out pHier, out pItemid));
                        buildPropStorage = (IVsBuildPropertyStorage)pHier;
                    }
                    if (configs == null)
                    {
                        configs = new List <string>();
                    }
                    string config;
                    ErrorHandler.ThrowOnFailure((dataObject as IVsCfg).get_DisplayName(out config));
                    configs.Add(config);
                }
            }

            string          assemblyInformationalVersion         = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion;
            SemanticVersion semanticAssemblyInformationalVersion = SemanticVersion.Parse(assemblyInformationalVersion);
            SemanticVersion semanticToolVersionInProject;
            bool            semanticToolVersionInProjectSpecified = SemanticVersion.TryParse(GetPropertyValue(NuBuildToolVersionPropertyTag), out semanticToolVersionInProject);

            if (!semanticToolVersionInProjectSpecified ||
                semanticToolVersionInProject < semanticAssemblyInformationalVersion)
            {
                SetPropertyValue(NuBuildToolVersionPropertyTag, assemblyInformationalVersion);
            }
            else if (semanticToolVersionInProjectSpecified &&
                     semanticToolVersionInProject > semanticAssemblyInformationalVersion)
            {
                throw new InvalidOperationException(String.Format("The project properties are edited with a higher version NuBuild ({0}). Update the NuBuild project system from {1} to the latest version!",
                                                                  semanticToolVersionInProject, assemblyInformationalVersion));
            }
        }
コード例 #2
0
ファイル: PropertyPage.cs プロジェクト: Plankankul/SpecSharp
        private void SetBuildStorage()
        {
            // Get the build storage associated with this property page.
            buildStorage = null;
            if (configs != null)
            {
                foreach (object config in configs)
                {
                    if (config != null)
                    {
                        // try to retrieve the project using IVs(Cfg)BrowseObject
                        IVsHierarchy    project = null;
                        IVsBrowseObject browse  = config as IVsBrowseObject;
                        if (browse != null)
                        {
                            uint itemid;
                            browse.GetProjectItem(out project, out itemid);
                        }
                        else
                        {
                            IVsCfgBrowseObject cfgBrowse = config as IVsCfgBrowseObject;
                            if (cfgBrowse != null)
                            {
                                uint itemid;
                                cfgBrowse.GetProjectItem(out project, out itemid);
                            }
                        }

                        // try to cast the project to a buildstorage
                        buildStorage = project as IVsBuildPropertyStorage;
                        if (buildStorage != null)
                        {
                            return; // we are done.
                        }
                    }
                }
            }
        }