(1) Install VS 2010 SP1 SDK (2) Tool -- Extension Manager, search VSPackage, install VSPackage Template and VSPackage Builder template (3) New Project, the Builder, Drag on "Add Toolbar" from toolbox, add two Combo, one button. Connect them to Group1. Now all will show up in Toolbar. Code to get Configuration Data from Server Http Endpoint--- must write in a seperate class file or Builder will overwrite it. class Configurator { public static string StartProjectName { get; private set; } public static void SetStartArguments(EnvDTE.DTE dte,string currEnvCombo, string currVerCombo) { foreach (Project p in dte.Solution.Projects) { if (p.Name == StartProjectName) p.ConfigurationManager.ActiveConfiguration.Properties.Item("StartArguments").Value = "env="+currEnvCombo+"\r\nver="+currVerCombo+"\r\nwebdata="+data; } } static string data = ""; public static void ReadConfigurationFromServer(ref string[] envArray, ref string[] verArray) { // Get Configuration from Server for all (env ver) and set two combo, start project etc. WebClient wc = new WebClient(); data = wc.DownloadString("http://www.cnn.com").Substring(300, 10); StartProjectName = "WpfApplication1"; envArray=new string[]{"UAT","LIVE","Local"}; verArray=new string[]{"Trading (London)","Trading (NYC)","Sales"}; } } public VSPackage1PackageBase() { Configurator.ReadConfigurationFromServer(ref envComboChoices, ref verComboChoices); } protected virtual void envComboExecuteHandler(object sender, EventArgs e) { ... Configurator.SetStartArguments(GetService(typeof(DTE)) as DTE, currentenvComboChoice, currentverComboChoice); Deployment: VSPackage project auto generate .vsix file for installation. But Do check vsixmanifest file "Select Editions" to include all VS.net 2010 editions
Monday, July 28, 2014
VS.Net Environment Configuration "Add-in" -- now called VS Package
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment