{"id":21763627,"url":"https://github.com/eduherminio/dotnet-combine","last_synced_at":"2025-04-13T13:41:56.051Z","repository":{"id":40003820,"uuid":"312713537","full_name":"eduherminio/dotnet-combine","owner":"eduherminio","description":".NET global tool that allows you to combine multiple C# source files into a single one, create a .zip with multiple files, etc.","archived":false,"fork":false,"pushed_at":"2024-06-11T07:39:09.000Z","size":157,"stargazers_count":26,"open_issues_count":5,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-27T04:41:36.023Z","etag":null,"topics":["dotnet-tool","net-6","zip"],"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/eduherminio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-14T00:22:20.000Z","updated_at":"2025-03-10T13:44:29.000Z","dependencies_parsed_at":"2023-01-29T23:15:44.261Z","dependency_job_id":"11813fa4-9793-4c49-b470-23e2d647d8b3","html_url":"https://github.com/eduherminio/dotnet-combine","commit_stats":{"total_commits":83,"total_committers":5,"mean_commits":16.6,"dds":0.3975903614457831,"last_synced_commit":"32a06df0a6510276fbd791c1cd2e96e7ee1d1fb6"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eduherminio%2Fdotnet-combine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eduherminio%2Fdotnet-combine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eduherminio%2Fdotnet-combine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eduherminio%2Fdotnet-combine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eduherminio","download_url":"https://codeload.github.com/eduherminio/dotnet-combine/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248724417,"owners_count":21151557,"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":["dotnet-tool","net-6","zip"],"created_at":"2024-11-26T12:15:53.530Z","updated_at":"2025-04-13T13:41:56.028Z","avatar_url":"https://github.com/eduherminio.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dotnet-combine\n\n[![GitHub Actions][githubactionslogo]][githubactionslink]\n\n[![NuGet][nugetlogo]][nugetlink]\n\n[![Code coverage][coveragelogo]][coveragelink]\n[![Sonar vulnerabilities][sonarvulnerabilitieslogo]][sonarqubelink]\n[![Sonar bugs][sonarbugslogo]][sonarqubelink]\n[![Sonar code smells][sonarcodesmellslogo]][sonarqubelink]\n\n`dotnet-combine` is .NET global tool that allows you to:\n\n- Merge multiple C# source files (`.cs`) into a single one.\n- Generate a `.zip` with the specified files within a directory.\n\n## Installing `dotnet-combine`\n\n.NET 6 SDK is required to use this tool. You can download it from [here](https://dotnet.microsoft.com/download/dotnet/6.0).\n\nThe tool can be installed globally by running:\n\n`dotnet tool install -g dotnet-combine`\n\nMore info about installing dotnet tools can be found [here](https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools).\n\nOnce installed, `dotnet-combine --help` should show you the general options:\n\n```bash\n  single-file    Combines multiple source code files (.cs) into a single one.\n\n  zip            Zips multiple files.\n\n  help           Display more information on a specific command.\n\n  version        Display version information.\n```\n\n## `dotnet-combine single-file`\n\n`dotnet-combine single-file` combines multiple C# source files (`.cs`) into a single, valid one.\n\nThis tool, originally inspired by [TomKirby/CGCompactor](https://github.com/TomKirby/CGCompactor), is handy if you need to submit a single source file somewhere; but you prefer to develop your solution locally using your preferred IDE and structuring it in multiple files.\n\nSome examples are competitive programming contests such as [Google Code Jam](https://codingcompetitions.withgoogle.com/codejam), [CodeChef](https://www.codingame.com/), [CodingGame](https://www.codingame.com/), etc.\n\nHelp for `dotnet-combine single-file` can be accessed by running:\n\n`dotnet-combine single-file --help`\n\n```bash\nUsage: dotnet-combine single-file \u003cINPUT\u003e [options]\n\n  input (pos. 0)     Required.\n                     Input path.\n\n  -o, --output       Output path (file or dir).\n                     If no dir path is provided (i.e. --output file.cs), the file will be created in the input dir.\n                     If no filename is provided (i.e. --output dir/), a unique name will be used.\n\n  -f, --overwrite    (Default: false)\n                     Overwrites the output file (if it exists).\n\n  --exclude          (Default: bin/ obj/)\n                     Excluded files and directories, separated by semicolons (;).\n\n  -p, --prefix       Prefix for the output file.\n\n  -s, --suffix       Suffix for the output file\n\n  -v, --verbose      (Default: false)\n                     Verbose output. Shows combined files, progress, etc.\n\n  --format           (Default: false)\n                     Formats output file. Enabling it slows down file generation process.\n\n  --help             Display this help screen.\n\n  --version          Display version information.\n```\n\n### `dotnet-combine single-file` usage examples\n\nIf you want to merge the source code of `MyAmazingProject.csproj`, located in `C:/MyAmazingProject`, you can simply do:\n\n```bash\ndotnet-combine single-file C:/MyAmazingProject\n```\n\nThat will generated a file under `C:/MyAmazingProject/`. Since having that file there may conflict with your project compilation, you probably want it to be created somewhere else, let's say, under `C:/tmp/`. You can use `--output` for that:\n\n```bash\ndotnet-combine single-file C:/MyAmazingProject --output C:/tmp/\n```\n\nIf you want that output file to have a specific name, you can also provide it:\n\n```bash\ndotnet-combine single-file C:/MyAmazingProject --output C:/tmp/amazing.cs\n```\n\nThe option `--override` can be used in subsequent runs to replace that file:\n\n```bash\ndotnet-combine single-file C:/MyAmazingProject --override --output C:/tmp/amazing.cs\n```\n\nIf you prefer to keep different versions of your output file, but would still like to identify them, you can use `--prefix` and/or `--suffix` together with your output dir in `--output`:\n\n```bash\ndotnet-combine single-file C:/MyAmazingProject --output C:/tmp/ --prefix amazing_\ndotnet-combine single-file C:/MyAmazingProject --output C:/tmp/ --suffix _amazing\n```\n\nBy default, `bin/` and `obj/` directories are excluded. That can be modified using `--exclude`:\n\n```bash\ndotnet-combine single-file C:/MyAmazingProject --output C:/tmp/ --prefix amazing_ --exclude \"bin/;obj/;AutogeneratedDir/;AssemblyInfo.cs\"\n```\n\nIf you want your `MyAmazingProject.csproj` files to be combined every time you build the project in release mode, you can integrate `dotnet-combine single-file` as a MsBuild target in your .csproj file:\n\n```xml\n  \u003cTarget Name=\"dotnet-combine single-file\" AfterTargets=\"Build\" DependsOnTargets=\"Build\" Condition=\"'$(Configuration)' == 'Release' \"\u003e\n    \u003cMessage Importance=\"high\" Text=\"Running dotnet-combine tool\"/\u003e\n    \u003cMessage Importance=\"high\" Text=\"dotnet-combine single-file $(MSBuildProjectDirectory) --overwrite --output $(MSBuildProjectDirectory)/bin/ --prefix amazing_ --exclude \u0026quot;bin/;obj/;AutogeneratedDir/;AssemblyInfo.cs\u0026quot;\"/\u003e\n    \u003cExec Command=\"dotnet-combine single-file $(MSBuildProjectDirectory) --overwrite --output $(MSBuildProjectDirectory)/bin/ --prefix amazing_ --exclude \u0026quot;bin/;obj/;AutogeneratedDir/;AssemblyInfo.cs\u0026quot;\"/\u003e\n  \u003c/Target\u003e\n```\n\n## `dotnet-combine zip`\n\n`dotnet-combine zip` generates a `.zip` with the specified files within a given directory.\n\nCurrently it supports filtering files by extension and excluding both files and directories.\n\nThis tool can be used for more general purposes than the previous one. Some of them can be:\n\n- Extracting all `.pdf` files from a folder in your hard drive with complex hierarchies that has them mixed up with other files (`.docx`, `.pptx`, `.jpg`, etc.).\n\n- Extracting all `.mp3` files from your mirrored cloud's folder.\n\n- Extracting all `.css` files from a web development project.\n\n- Extracting all the relevant source code files (`.sln`, `.csproj`, `.cs`, `.json`, `.razor`, `.xaml`, etc.) from your .NET project in a GitHub Action step, to be able to make them available as an artifact.\n\n- ...\n\nHelp for `dotnet-combine zip` can be accessed by running:\n\n`dotnet-combine zip --help`\n\n```bash\nUsage: dotnet-combine zip \u003cINPUT\u003e [options]\n\n  input (pos. 0)     Required.\n                     Input path (file or dir).\n\n  -o, --output       Output path (file or dir).\n                     If no dir path is provided (i.e. --output file.cs), the file will be created in the input\n                     directory.\n                     If no filename is provided (i.e. --output dir/), a unique name will be used.\n\n  --extensions       (Default: .sln .csproj .cs .json)\n                     File extensions to include, separated by semicolons (;).\n\n  -f, --overwrite    (Default: false)\n                     Overwrites the output file (if it exists).\n\n  --exclude          (Default: bin/ obj/)\n                     Excluded files and directories, separated by semicolons (;).\n\n  -p, --prefix       Prefix for the output file.\n\n  -s, --suffix       Suffix for the output file.\n\n  -v, --verbose      (Default: false)\n                     Verbose output. Shows compressed files, progress, etc.\n\n  --help             Display this help screen.\n\n  --version          Display version information.\n```\n\n### `dotnet-combine zip` usage examples\n\nIf you want to create a `.zip` with all the C++ source code in your `MyGeekyProject` project, located in `/home/ed/GeekyProject/`, you can simply do:\n\n```bash\ndotnet-combine zip /home/ed/GeekyProject --extensions \".cpp;cxx:cc;.h;.hpp\"\n```\n\nThat will generated a file under `/home/ed/GeekyProject`. If you plan to create `.zip` files regularly, you may want to place them somewhere else, such as `/home/ed/GeekyProject/artifacts/`. You can use `--output` for that:\n\n```bash\ndotnet-combine zip /home/ed/GeekyProject --extensions \".cpp;cxx:cc;.h;.hpp;\" --output /home/ed/GeekyProject/artifacts/\n```\n\nIf you want that output file to have a specific name, you can also provide it using `--output`:\n\n```bash\ndotnet-combine zip /home/ed/GeekyProject --extensions \".cpp;cxx:cc;.h;.hpp\" --output /home/ed/GeekyProject/artifacts/src_v1`\n```\n\nThe tool will prevent you from generating another file with the same name unless you use `--override` (also abbreviated as `-f`):\n\n```bash\ndotnet-combine zip /home/ed/GeekyProject -f --extensions \".cpp;cxx:cc;.h;.hpp\" --output /home/ed/GeekyProject/artifacts/src_v1\n```\n\nHowever, you may prefer to keep different versions of your output file without having to worry about specifying different version numbers in the name. You can achieve that by only including a dir path in `--output`, and making use of `--prefix` and/or `--suffix`:\n\n```bash\ndotnet-combine zip /home/ed/GeekyProject --extensions \".cpp;cxx:cc;.h;.hpp\" --prefix geeky- --output /home/ed/GeekyProject/artifacts/\n```\n\nBy default, `bin/` and `obj/` directories are excluded. That can be modified by using `--exclude`:\n\n```bash\ndotnet-combine zip /home/ed/GeekyProject --extensions \".cpp;cxx:cc;.h;.hpp;.vcxproj;\" --prefix geeky- --output /home/ed/GeekyProject/artifacts/ --exclude \"build/;UnwantedFile.h\"\n```\n\nIf you want to pack your `MyGeekyProject` source files as part of your GitHub Actions CI pipeline, you can do it like this:\n\n```yaml\n    steps:\n    - uses: actions/checkout@v2.3.3\n\n    - name: Install dotnet-combine locally.\n      run: |\n        dotnet new tool-manifest\n        dotnet tool install dotnet-combine\n\n    - name: Create source code artifact using dotnet-combine.\n      run: dotnet dotnet-combine zip . --extensions \".cpp;cxx:cc;.h;.hpp;.vcxproj;\" --prefix geeky- --output ./artifacts/ --exclude \"build/;UnwantedFile.h\"\n\n    - name: Upload source code artifact.\n      uses: actions/upload-artifact@v2\n      with:\n        name: source-code-ci-${{ github.run_number }}\n        path: artifacts/\n        if-no-files-found: error\n```\n\n## Additional notes\n\n- Although `dotnet-combine` does support `\\` path separators in Windows, bear in mind that using them will prevent your commands/targets from being cross-platform.\n\n- If you want use a suffix that starts with a dash (`-`), you can do that by using '[double-dash](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html)' (`--`) to indicate the end of options (i.e. `dotnet-combine single-file ./MyDir --suffix -- -my-suffix`).\n\n## Contributing\n\nIf you experience difficulties using `dotnet-combine`, please [open an issue](https://github.com/eduherminio/dotnet-combine/issues/new/choose) detailing what you want to achieve and the command you've tried.\n\nFeature requests are welcome.\n\nPRs are also more than welcome, but feel free to open an issue before carrying out any major changes to avoid any misalignments.\n\n[githubactionslogo]: https://github.com/eduherminio/dotnet-combine/actions/workflows/ci.yml/badge.svg\n[githubactionslink]: https://github.com/eduherminio/dotnet-combine/actions/workflows/ci.yml\n[nugetlogo]: https://img.shields.io/nuget/v/dotnet-combine.svg?style=flat-square\u0026label=nuget\n[nugetlink]: https://www.nuget.org/packages/dotnet-combine\n[coveragelogo]: https://sonarcloud.io/api/project_badges/measure?project=eduherminio_dotnet-combine\u0026metric=coverage\n[coveragelink]: https://sonarcloud.io/dashboard?id=eduherminio_dotnet-combine\n[sonarqubelink]: https://sonarcloud.io/dashboard?id=eduherminio_dotnet-combine\n[sonarqualitylogo]: https://sonarcloud.io/api/project_badges/measure?project=eduherminio_dotnet-combine\u0026metric=alert_status\n[sonarvulnerabilitieslogo]: https://sonarcloud.io/api/project_badges/measure?project=eduherminio_dotnet-combine\u0026metric=vulnerabilities\n[sonarbugslogo]: https://sonarcloud.io/api/project_badges/measure?project=eduherminio_dotnet-combine\u0026metric=bugs\n[sonarcodesmellslogo]: https://sonarcloud.io/api/project_badges/measure?project=eduherminio_dotnet-combine\u0026metric=code_smells\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feduherminio%2Fdotnet-combine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feduherminio%2Fdotnet-combine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feduherminio%2Fdotnet-combine/lists"}