Get value for SetEnvUIConfig from real environment settings ?

Topics: Bindings File, Settings Management and SSO, IIS and Web Services
Jun 19, 2013 at 8:36 AM
Is it possible to get values for a UIConfig Item from the machine settings.

What i am trying to accomplish is speeding up the deployment process.

For example on my local machine user name and password for a wcf appool is "BizTalk"

Now when I go to My Computer (System properties, Environment Variables) and add the two props :

VDIR_UserName
VDIR_Password

With their respective values, I want them to be entered in the prompt.
If the envronment settings are not set, the prompts will be empty so we really have to type them....

Is this possible ?
Jun 19, 2013 at 10:46 AM
Didn't think is was possible......

Made a slight modification to SetUiEnv to make it possible.....
 /// <summary>
  /// Load a configuration file, and return an instance of this class.
  /// </summary>
  /// <param name="filename"></param>
  /// <returns></returns>
  public static SetEnvUIConfig LoadFromFile(string filename)
  {
     SetEnvUIConfig config = null;

     XmlSerializer serializer = new XmlSerializer(typeof(SetEnvUIConfig));
     using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
     {
         config = (SetEnvUIConfig)serializer.Deserialize(fs);
     }
     foreach (SetEnvUIConfigItem item in config.ConfigItems)
     {
         // try to read the setting from the environmentsettings defined on the machine
         try
         {
             string value = Environment.GetEnvironmentVariable(item.EnvironmentVarName);
             if (!String.IsNullOrEmpty(value))
             {
                 item.PromptValue = value;
             }
         }
         catch (Exception ex)
         {

         }
     }
     return config;
  }
Jun 19, 2013 at 10:51 AM
This makes it alse possible to define a variable ENV_SETTINGS with the path to the installed settings file.

This way you make sure you always select the same environment on tyhe same machine !
Unintended but pleasant bahaviour.
Coordinator
Jun 19, 2013 at 4:35 PM
Hi,

Unfortunately you went through far more trouble than was necessary. Setting environment variables is not the right approach.

I'm not clear on whether you are doing this for your servers or developer machine. If it's for your developer machine, there are already defaults for all of the necessary settings when you're deploying from Visual Studio.

If it's for a server, you should add settings (rows) to the Excel settings spreadsheet for VDIR_UserName and any others you need to override. Add the same setting names to the .btdfproj's PropsFromEnvSettings ItemGroup and the setting values will be carried over into MSBuild properties. Then remove those settings from InstallWizard.xml as they are no longer necessary. The only thing that you must specify outside of the settings spreadsheet is ENV_SETTINGS. If you are trying to hard-code that to a machine, you can simply add a property in a PropertyGroup named ENV_SETTINGS and specify the path. You can even use the Condition attribute on the PropertyGroup to limit it to a specific machine name if necessary.

Thanks,
Tom
Jun 19, 2013 at 7:17 PM
Thans for your response !


I knew it works the way you described it.

I wanted to keep the dialog of SetUiEnv but wanted to provide defaults for it...
So on the dev and test machines I can do a quick setup Because the SetUiEnv has correct defaults for every setting so it is just a matter of hitting that enter button.

The Administrators on the Acceptance environment still have to type the password because I don't know those passwords on those environments (and don't want to know). So i cannot enter them in the settings spreadsheet.

But the behaviour as it is now is really great !