internal override void ExecuteInternal(IBuildConfiguration config) { // Validate we have inputs... if (InputConfigFiles is null || !InputConfigFiles.Any()) { Log.LogMessage("No input config files were found"); return; } if (GeneratedAppConfig is null || !GeneratedAppConfig.Any()) { Log.LogError("Input app.config's were found, however no outputs were found."); return; } // Get root app.config var rootConfigFile = GetTaskItem(InputConfigFiles, "app.config"); if (rootConfigFile is null) { // this should never happen... Log.LogError("We could not locate an 'app.config'. Please file a bug."); return; } // Reset output directory var fi = new FileInfo(GeneratedAppConfig.First().ItemSpec); if (fi.Directory.Exists) { fi.Directory.Delete(true); } fi.Directory.Create(); // Get Transform config var transformFile = GetTaskItem(InputConfigFiles, $"app.{AppConfigEnvironment}.config"); var outputs = GeneratedAppConfig.Select(x => x.ToExpectedAppConfig()); var generator = new ConfigurationManagerTransformationGenerator(config) { BaseConfigPath = rootConfigFile.ItemSpec, TransformFilePath = transformFile.ItemSpec, ExpectedConfigs = outputs }; generator.Execute(); }
internal override void ExecuteInternal(IBuildConfiguration config) { //if (!Debugger.IsAttached) // Debugger.Launch(); if (!InputConfigFiles.Any()) { Log.LogMessage("No input config files were found"); return; } //var configsOutputDirPath = Path.Combine(IntermediateOutputPath, "configs"); //var configsOutputDir = new DirectoryInfo(configsOutputDirPath); var rootConfigFile = InputConfigFiles.FirstOrDefault(x => x.ItemSpec.Equals("app.config", StringComparison.InvariantCultureIgnoreCase)); var transformFile = InputConfigFiles.FirstOrDefault(x => x.ItemSpec.Equals($"app.{AppConfigEnvironment}.config", StringComparison.InvariantCultureIgnoreCase)); if (transformFile is null) { Log.LogMessage($"No transform config 'app.{AppConfigEnvironment.ToLower()}.config' could be found in the output directory."); return; } if (rootConfigFile is null) { // this should never happen... Log.LogError("We could not locate an 'app.config' in the output directory. Please file a bug."); return; } var generator = new ConfigurationManagerTransformationGenerator(config) { BaseConfigPath = rootConfigFile.ItemSpec, TransformFilePath = transformFile.ItemSpec }; generator.Execute(); _outputs.AddRange(generator.Outputs); }