/// <summary> /// Add Bar Descriptor to each project. /// </summary> private void AddBarDescriptor() { try { DTE dte = _applicationObject as DTE; Projects projs = dte.Solution.Projects; List<Project> projList = new List<Project>(); foreach (Project proj in projs) { projList.Add(proj); } while (projList.Count > 0) { Project proj = projList.ElementAt(0); projList.RemoveAt(0); Configuration config; Property prop; try { config = proj.ConfigurationManager.ActiveConfiguration; prop = config.Properties.Item("ConfigurationType"); } catch { config = null; prop = null; } if (prop == null) { if (proj.ProjectItems != null) { foreach (ProjectItem projItem in proj.ProjectItems) { if (projItem.SubProject != null) projList.Add(projItem.SubProject); } } continue; } if (Convert.ToInt16(prop.Value) != Convert.ToInt16(ConfigurationTypes.typeApplication)) continue; if (config.PlatformName != BLACKBERRY && config.PlatformName != BLACKBERRYSIMULATOR) continue; ProjectItem baritem = proj.ProjectItems.Item(BAR_DESCRIPTOR); string n = proj.Name; if (baritem == null) { tokenProcessor = new TokenProcessor(); Debug.WriteLine("Add bar descriptor file to the project"); string templatePath = dte.Solution.ProjectItemsTemplatePath(proj.Kind); templatePath += BAR_DESCRIPTOR_PATH + BAR_DESCRIPTOR; tokenProcessor.AddReplace(@"[!output PROJECT_NAME]", proj.Name); string destination = System.IO.Path.GetFileName(templatePath); // Remove directory used in previous versions of this plug-in. string folder = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(proj.FullName), proj.Name + "_barDescriptor"); if (Directory.Exists(folder)) { try { Directory.Delete(folder); } catch (Exception e) { } } folder = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(proj.FullName), "BlackBerry-" + proj.Name); System.IO.Directory.CreateDirectory(folder); destination = System.IO.Path.Combine(folder, destination); tokenProcessor.UntokenFile(templatePath, destination); ProjectItem projectitem = proj.ProjectItems.AddFromFile(destination); } } } catch (Exception e) { Debug.WriteLine(e.Message); } }
public override object GetProperty(int propId) { // Fix MS bug switch ((__VSHPROPID)propId) { case __VSHPROPID.VSHPROPID_DefaultNamespace: TokenProcessor processor = new TokenProcessor(); return processor.GetFileNamespace(this.Url, this); case __VSHPROPID.VSHPROPID_DefaultEnableBuildProjectCfg: return base.GetProperty(propId); default: return base.GetProperty(propId); } }
/// <summary> /// Gets the properties of the project node. /// </summary> /// <param name="propId">The __VSHPROPID of the property.</param> /// <returns>A property dependent value. See: <see cref="__VSHPROPID"/> for details.</returns> public override object GetProperty(int propId) { switch ((__VSHPROPID)propId) { case __VSHPROPID.VSHPROPID_ConfigurationProvider: return this.ConfigProvider; case __VSHPROPID.VSHPROPID_ProjectName: return this.Caption; case __VSHPROPID.VSHPROPID_ProjectDir: return this.ProjectFolder; case __VSHPROPID.VSHPROPID_TypeName: return this.ProjectType; case __VSHPROPID.VSHPROPID_ShowProjInSolutionPage: return this.ShowProjectInSolutionPage; case __VSHPROPID.VSHPROPID_ExpandByDefault: return true; // Use the same icon as if the folder was closed case __VSHPROPID.VSHPROPID_OpenFolderIconIndex: return GetProperty((int)__VSHPROPID.VSHPROPID_IconIndex); case __VSHPROPID.VSHPROPID_DefaultNamespace: TokenProcessor processor = new TokenProcessor(); return processor.GetFileNamespace(this.Url, this); } switch ((__VSHPROPID2)propId) { case __VSHPROPID2.VSHPROPID_SupportsProjectDesigner: return this.SupportsProjectDesigner; case __VSHPROPID2.VSHPROPID_PropertyPagesCLSIDList: return Utilities.CreateSemicolonDelimitedListOfStringFromGuids(this.GetConfigurationIndependentPropertyPages()); case __VSHPROPID2.VSHPROPID_CfgPropertyPagesCLSIDList: return Utilities.CreateSemicolonDelimitedListOfStringFromGuids(this.GetConfigurationDependentPropertyPages()); case __VSHPROPID2.VSHPROPID_PriorityPropertyPagesCLSIDList: return Utilities.CreateSemicolonDelimitedListOfStringFromGuids(this.GetPriorityProjectDesignerPages()); case __VSHPROPID2.VSHPROPID_Container: return true; default: break; } return base.GetProperty(propId); }
private void AddBarDescriptor() { try { DTE dte = _applicationObject as DTE; Projects projs = dte.Solution.Projects; foreach (Project proj in projs) { VCProject vcProj = proj.Object as VCProject; if (vcProj == null) return; IVCCollection cfgs = vcProj.Configurations; bool isBlackBerry = false; foreach (VCConfiguration cfg in cfgs) { if (cfg.ConfigurationType != ConfigurationTypes.typeApplication) return; if (cfg.Platform.Name == BLACKBERRY || cfg.Platform.Name == BLACKBERRYSIMULATOR) isBlackBerry = true; } if (!isBlackBerry) continue; ProjectItem baritem = proj.ProjectItems.Item(BAR_DESCRIPTOR); if (baritem == null && !File.Exists(vcProj.ProjectDirectory + BAR_DESCRIPTOR)) { tokenProcessor = new TokenProcessor(); Debug.WriteLine("Add bar descriptor file to the project"); string templatePath = dte.Solution.ProjectItemsTemplatePath(proj.Kind); templatePath += BAR_DESCRIPTOR_PATH + BAR_DESCRIPTOR; tokenProcessor.AddReplace(@"[!output PROJECT_NAME]", proj.Name); string destination = System.IO.Path.GetFileName(templatePath); destination = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(proj.FullName), destination); tokenProcessor.UntokenFile(templatePath, destination); ProjectItem projectitem = proj.ProjectItems.AddFromFile(destination); } } } catch (Exception e) { Debug.WriteLine(e.Message); } }