private CustomConfigurationSource GetCommandLineConfigSource() { var commandLineConfigSource = new CustomConfigurationSource(); commandLineConfigSource.Set(SettingsKeys.PlatformName, this.PlatformName); commandLineConfigSource.Set(SettingsKeys.PlatformVersion, this.PlatformVersion); commandLineConfigSource.Set(SettingsKeys.RuntimePlatformName, this.RuntimePlatformName); commandLineConfigSource.Set(SettingsKeys.RuntimePlatformVersion, this.RuntimePlatformVersion); // Set the platform key and version in the format that they are represented in other sources // (like environment variables and build.env file). // This is so that this enables Configuration api to apply the hierarchical config. // Example: "--platform python --platform-version 3.6" will win over "PYTHON_VERSION=3.7" // in environment variable SetPlatformVersion(this.PlatformName, this.PlatformVersion); return(commandLineConfigSource); void SetPlatformVersion(string platformName, string platformVersion) { platformName = platformName == "nodejs" ? "node" : platformName; var platformVersionKey = $"{platformName}_version".ToUpper(); commandLineConfigSource.Set(platformVersionKey, platformVersion); } }
public static IConfigurationBuilder AddCustomSource(this IConfigurationBuilder configurationBuilder) { CustomConfigurationSource customConfigurationSource = new CustomConfigurationSource(); configurationBuilder.Add(customConfigurationSource); return(configurationBuilder); }
private CustomConfigurationSource GetCommandLineConfigSource() { var commandLineConfigSource = new CustomConfigurationSource(); return(commandLineConfigSource); }