Ejemplo n.º 1
0
        public MSBuild.Project Save(MSBuild.ProjectCollection collection, string location)
        {
            location = Path.Combine(location, _name);
            Directory.CreateDirectory(location);

            var    project     = new MSBuild.Project(collection);
            string projectFile = Path.Combine(location, _name) + ProjectType.ProjectExtension;

            if (_isUserProject)
            {
                projectFile += ".user";
            }
            project.Save(projectFile);

            if (ProjectType != ProjectType.Generic)
            {
                var projGuid = Guid.NewGuid();
                project.SetProperty("ProjectTypeGuid", TypeGuid.ToString());
                project.SetProperty("Name", _name);
                project.SetProperty("ProjectGuid", projGuid.ToString("B"));
                project.SetProperty("SchemaVersion", "2.0");
                var group = project.Xml.AddPropertyGroup();
                group.Condition = " '$(Configuration)' == 'Debug' ";
                group.AddProperty("DebugSymbols", "true");
                group           = project.Xml.AddPropertyGroup();
                group.Condition = " '$(Configuration)' == 'Release' ";
                group.AddProperty("DebugSymbols", "false");
            }

            foreach (var processor in ProjectType.Processors)
            {
                processor.PreProcess(project);
            }

            foreach (var item in Items)
            {
                item.Generate(ProjectType, project);
            }

            foreach (var processor in ProjectType.Processors)
            {
                processor.PostProcess(project);
            }

            project.Save();

            return(project);
        }
Ejemplo n.º 2
0
        private void GetNamesFromWrapper()
        {
            if (this.TypeLibWrapper != null)
            {
                TLIBATTR[] attr = new TLIBATTR[1];
                attr[0].guid         = this.TypeGuid;
                attr[0].wMajorVerNum = (ushort)this.MajorVersionNumber;
                attr[0].wMinorVerNum = (ushort)this.MinorVersionNumber;
                attr[0].LCID         = Convert.ToUInt32(this.LCID);
                string name;
                if (TypeLibWrapper.GetMainWrapperFriendlyName(attr, out name) == VSConstants.S_OK)
                {
                    this.typeName = name;
                    this.ItemNode.Rename(name);
                }
                if (TypeLibWrapper.GetMainWrapperFilename(attr, out name) == VSConstants.S_OK)
                {
                    this.wrapperFileName = name;
                }
                else
                {
                    Version version = new Version(MajorVersionNumber, MinorVersionNumber);

                    var key = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("Typelib\\" + TypeGuid.ToString("B") + "\\" + version.ToString());
                    if (key != null)
                    {
                        name = (string)key.GetValue("PrimaryInteropAssemblyName");
                        var asmName  = new AssemblyName(name);
                        var assembly = Assembly.Load(asmName);
                        this.wrapperFileName = assembly.Location;
                    }
                }
            }
            // get the typelib description
            string typeLibPath = QueryPathOfRegTypeLib(this.TypeGuid, (short)MajorVersionNumber, (short)MinorVersionNumber, Convert.ToInt32(this.LCID));

            typeLibPath = typeLibPath.Replace("\0", "");
            if (File.Exists(typeLibPath))
            {
                ITypeLib itypelib;
                int      iresult = LoadTypeLib(typeLibPath, out itypelib);
                if (iresult == VSConstants.S_OK && itypelib != null)
                {
                    System.Runtime.InteropServices.ComTypes.ITypeLib itl = itypelib as System.Runtime.InteropServices.ComTypes.ITypeLib;
                    if (itl != null)
                    {
                        string strName, strDocString, strHelpFile;
                        int    iHelpContext;
                        itl.GetDocumentation(-1, out strName, out strDocString, out iHelpContext, out strHelpFile);
                        description = strDocString;
                    }
                }
            }
        }