{"id":22573250,"url":"https://github.com/phillipsj/cake.xdttransform","last_synced_at":"2025-03-28T15:12:48.475Z","repository":{"id":45231342,"uuid":"44379650","full_name":"phillipsj/Cake.XdtTransform","owner":"phillipsj","description":"Provides XDT based transformations for config files.","archived":false,"fork":false,"pushed_at":"2021-12-30T18:29:52.000Z","size":150,"stargazers_count":6,"open_issues_count":0,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-26T00:03:09.225Z","etag":null,"topics":["cake","cake-addin","cake-build"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phillipsj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-16T10:58:29.000Z","updated_at":"2022-05-31T23:15:57.000Z","dependencies_parsed_at":"2022-08-26T03:42:04.509Z","dependency_job_id":null,"html_url":"https://github.com/phillipsj/Cake.XdtTransform","commit_stats":null,"previous_names":["cake-contrib/cake.xdttransform"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phillipsj%2FCake.XdtTransform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phillipsj%2FCake.XdtTransform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phillipsj%2FCake.XdtTransform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phillipsj%2FCake.XdtTransform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phillipsj","download_url":"https://codeload.github.com/phillipsj/Cake.XdtTransform/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246049631,"owners_count":20715511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cake","cake-addin","cake-build"],"created_at":"2024-12-08T02:14:31.533Z","updated_at":"2025-03-28T15:12:48.444Z","avatar_url":"https://github.com/phillipsj.png","language":"C#","funding_links":["https://www.buymeacoffee.com/aQPnJ73O8"],"categories":[],"sub_categories":[],"readme":"# Cake.XdtTransform\n\nThis was adapted from an [open issue](https://github.com/cake-build/cake/issues/321) on Github that shows\nhow to perform an XDT config transform. The issue is still open, but I didn't there would need to be an\nextra dependency pulled in unless you really needed it and that is why it is still open.\n\n## Support\n\nIf you would like to support this project, there are several opportunities. Pull Requests, bug reports, documentation, promotion, and encouragement are all great ways. If you would like to contribute monetarily, you can [Buy Me a Coffee](https://www.buymeacoffee.com/aQPnJ73O8).\n\n## Contributions\n\nThis repository uses GitHub Flow, please create a feature branch then submit your PRs to main.\n\n## Usage\n\n```csharp\n#addin nuget:?package=Cake.XdtTransform\u0026version=0.18.0\u0026loaddependencies=true\n\nvar target = Argument(\"target\", \"Default\");\n\nTask(\"TransformConfig\")\n  .Does(() =\u003e\n{\n  var sourceFile      = File(\"web.config\");\n  var transformFile   = File(\"web.release.config\");\n  var targetFile      = File(\"web.target.config\");\n  XdtTransformConfig(sourceFile, transformFile, targetFile);\n});\n\nRunTarget(target);\n```\n\nHere is an example of applying multiple configs and showing encountered problems in console.\nTransformations usually do not notify user about potential problems like ‘transformation target element not found’. This may lead to silent problems, for example, someone renaming a config key, but forgetting about transformations – keep an eye on the log.  \n\n```csharp\n// Find and apply all pairs like Web.base.config + Web.ENV.config =\u003e Web.config\nvar environment = Argument(\"environmentName\", \"DEV\");\nTask(\"Transform-all-configs\")\n    .Does(() =\u003e\n    {\n\n        (string, string, string)[] trasfromations = GetPahts(environment, \"./\");\n\n        foreach ((var baseConfigPath, var transfromationConfigPath, var resultingConfigPath) in trasfromations)\n        {\n            WrtieLine(\"\");\n\n            Console.ForegroundColor = ConsoleColor.Green;\n            WriteLine($\"Running transform for: \\r\\n{baseConfigPath}\\r\\n{transfromationConfigPath}\");\n            Console.ForegroundColor = ConsoleColor.White;\n            var transformationLog = XdtTransformConfigWithDefaultLogger(\n                                                            File(baseConfigPath),\n                                                            File(transfromationConfigPath),\n                                                            File(resultingConfigPath));\n\n            var hasProblems = (transformationLog.HasError\n                                || transformationLog.HasException\n                                || transformationLog.HasWarning);\n\n            if(hasProblems == false)\n            {\n                continue;\n            }\n\n            Console.ForegroundColor = ConsoleColor.Red;\n            WriteLine($\"Tranfomration log has problems.\");\n            Console.ForegroundColor = ConsoleColor.White;\n\n            var problemEntries = transformationLog.Log\n                                            .Where(x =\u003e x.MessageType == \"Error\"\n                                                        || x.MessageType == \"Exception\"\n                                                        || x.MessageType == \"Warning\");\n\n            foreach (var entry in problemEntries)\n            {\n                WriteLine(entry);\n            }\n\n            Console.ForegroundColor = Console.Gray;\n        }\n    });\n```\n\n## Discussion\n\nFor questions and to discuss ideas \u0026 feature requests, use the [GitHub discussions on the Cake GitHub repository](https://github.com/cake-build/cake/discussions), under the [Extension Q\u0026A](https://github.com/cake-build/cake/discussions/categories/extension-q-a) category.\n\n[![Join in the discussion on the Cake repository](https://img.shields.io/badge/GitHub-Discussions-green?logo=github)](https://github.com/cake-build/cake/discussions)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphillipsj%2Fcake.xdttransform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphillipsj%2Fcake.xdttransform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphillipsj%2Fcake.xdttransform/lists"}