/// <summary> /// Generate dynamic parameters based on the connection strings in the Web.config. /// It will look at 2 Web.config files: /// 1. Web.config /// 2. Web.<configuration>.config (like Web.Release.config) /// This only works when -ProjectFile is used and -ConnectionString is not used. /// </summary> /// <returns>The dynamic parameters.</returns> public object GetDynamicParameters() { if (!string.IsNullOrEmpty(ProjectFile) && ConnectionString == null) { // Get the 2 Web.config files. PrepareFileFullPaths(); dynamicParameters = new RuntimeDefinedParameterDictionary(); if (string.Compare("ProjectFile", ParameterSetName) == 0) { // Parse the connection strings from the Web.config files. var names = WebsitesClient.ParseConnectionStringNamesFromWebConfig(fullWebConfigFile, fullWebConfigFileWithConfiguration); // Create a dynmaic parameter for each connection string using the same name. foreach (var name in names) { var parameter = new RuntimeDefinedParameter(); parameter.Name = name; parameter.ParameterType = typeof(string); parameter.Attributes.Add(new ParameterAttribute() { ParameterSetName = "ProjectFile", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Connection string from Web.config." } ); dynamicParameters.Add(name, parameter); } } } return(dynamicParameters); }