{"id":13408041,"url":"https://github.com/yevhen/Nake","last_synced_at":"2025-03-14T12:32:00.334Z","repository":{"id":8942036,"uuid":"10676049","full_name":"yevhen/Nake","owner":"yevhen","description":"Magic script-based C# task runner for .NET Core","archived":false,"fork":false,"pushed_at":"2024-06-21T21:32:18.000Z","size":34379,"stargazers_count":233,"open_issues_count":12,"forks_count":22,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-10-04T19:03:45.501Z","etag":null,"topics":["automation","build","c-sharp","developer-tools","dotnet","dotnet-core","runner","script","shell","task"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yevhen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2013-06-13T21:10:36.000Z","updated_at":"2024-10-02T09:16:25.000Z","dependencies_parsed_at":"2024-10-26T03:23:31.582Z","dependency_job_id":"b481bd31-970f-407c-99e4-d6509c63fd72","html_url":"https://github.com/yevhen/Nake","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yevhen%2FNake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yevhen%2FNake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yevhen%2FNake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yevhen%2FNake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yevhen","download_url":"https://codeload.github.com/yevhen/Nake/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243258495,"owners_count":20262298,"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":["automation","build","c-sharp","developer-tools","dotnet","dotnet-core","runner","script","shell","task"],"created_at":"2024-07-30T20:00:50.343Z","updated_at":"2025-03-14T12:32:00.309Z","avatar_url":"https://github.com/yevhen.png","language":"C#","readme":"![Nake](Logo.Wide.png)\n\nNake is a magic task runner tool for .NET Core. It's a hybrid of Shovel and Rake. The DSL for defining tasks is uniquely minimal and it's just plain (_naked_) C# code! Nake is built on top of the latest Roslyn release so you can use all of the latest C# features in you scripts and even more.\n\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/yevhen/Nake?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n[![Build status](https://ci.appveyor.com/api/projects/status/kors8n8y4r4xklop/branch/master?svg=true)](https://ci.appveyor.com/project/yevhen/nake/branch/master)\n[![NuGet](https://img.shields.io/nuget/v/Nake.svg?style=flat)](https://www.nuget.org/packages/Nake/)\n\n### How to install\n\nNake is built as dotnet tool. You can install it either globally of [locally](https://stu.dev/dotnet-core-3-local-tools/) (recommended):\n\n\tPM\u003e dotnet tool install Nake\n\n## Syntax cheatsheet\n\n```cs\n#r \"System                          //\n#r \"System.Core\"                    //\n#r \"System.Data\"                    //   #reference assemblies from the netstandard BCL   \n#r \"System.Xml\"                     //       (these are referenced by default)\n#r \"System.Xml.Linq\"                //    \n#r \"Microsoft.CSharp\"               //\n\n#r \"System.IO, Version=4.0...\"      //  you can reference assembly by its full name\n#r \"./Packages/nunit.dll\"           //        or by using relative path\n#r \"/usr/bin/SDK/Orleans.dll\"       //            or by absolute path\n                                        \n#r \"nuget: Streamstone, 2.0.0\"      //  Nake is using dotnetscript dependency resolution\n#r \"nuget: Newtonsoft.Json\"         //  so referencing nuget packages is fully supported\n#r \"nuget: Orleankka, 2.*\"          //  https://github.com/filipw/dotnet-script#nuget-packages-1\n\n#load \"Other.csx\"                   //      #load code from other script files\n#load \"Build/Another.csx\"           //  (both absolute and relative paths are fine)\n\nusing System;                       //\nusing System.IO;                    //      standard C# namespace imports\nusing System.Linq;                  //     (these are imported by default)\nusing System.Text;                  //  \nusing System.Threading.Tasks;       //    \nusing System.Collections.Generic;   //  \n\nusing static System.IO.Path;        //    C# \"using static members\" feature \nusing static System.Console;        //      will make you scripts more terse\n\nWriteLine(\"Are you ready? Y/N:\");   //      any code you put on the script level \nif (ReadLine() == \"N\")              //  will run before any of the tasks are executed\n    Exit(\"See you soon ...\");       //      (useful for one-off initialization)\n\nvar greeting = \"Hello\";             //   you can override any script-level variables \nvar who = \"world\";                  //  with the values passed from the command line\n\n/// Prints greeting                 //  this F#-style summary is shown in task listing\n[Nake] void Welcome()               //  [Nake] makes method runnable from command line\n{                                       \n    Write($\"{greeting},{who}!\");    //  forget ugly string.Format \u0026 string concatenation \n}                                   //   with built-in support for string interpolation\n\n[Nake] void Tell(\n    string what = \"Hello\",          //     for parameterized tasks you can supply\n    string whom = \"world\",          //     arguments directly from the command line\n    int times = 1,                  //          (string, int, boolean and \n    DayOfWeek when,                 //         enum arguments are supported)\n    bool quiet = false              //  + switch-like syntax for booleans (eg, --quiet)\n)\n{\n    var emphasis = quiet ? \"\" : \"!\";\n    for (; times \u003e 0; times--)\n\t    WriteLine($\"{what}, {whom} on {when}{emphasis}\");\n}                                   \n\n[Step] void Clean()                  //     Steps are tasks with 'run once' semantics      \n{                                    //     (foundation of any build automation tool)\n    Delete($\"{OutputPath}/*.*\");\t\n}                                   \n\n[Step] void Build(string cfg = \"Debug\")\n{\t\t\t\t\t                    \n    Clean();                        //  unlike popular tools, there is no special syntax\n    -------                         //     for specifying task (step) dependencies\n    MSBuild(\"Nake.sln\", cfg);       //    (it's just plain old C# method invocation)\n}                                       \n                                       \n[Step] void Test()\n{\t\t\t\t\t                    \n    Clean();                        //     you have complete control over decision,\n    Build();                        //  when and in what order dependent steps should run\n    -------                         //      (and Nake makes sure of run-once behavior)\n    NUnit($\"{OutputPath}/*.Tests.dll\");   \n}\n\n[Step] void Publish(bool beta = false)\n{\t\t\t\t\t                    \n    Test();                         //   sometimes, you need to execute the same step but with\n    Build(\"Release\");               //  different args. Unlike other build automation tools\n    ------                          //  there is no special syntax to force step to run again, \n    Nuget(\"Nake.nuspec\", beta);     //       you just invoke it with different arguments!\n}                                       \n\nvar apiKey = \"$NugetKey$\";          //      $var$ is the shortcut syntax for getting \nPush(apiKey, \"{PackagePath}\");      //          value of environment variable\n\nconst string ApiKey = \"$APIKEY$\";   //     environment variables defined in constant scopes\nvoid Push(string key = \"$APIKEY$\")  //       evaluated once at compile-time (ie, inlined)\n\nvar ApiKey = \"$APIKEY$\";            //     environment variables defined in variable scopes\nWrite(\"$APIKEY$\");                  //       evaluated at invocation-time (dynamic)\n\nWrite(\"$NakeStartupDirectory$\");    //       these special environment variables\nWrite(\"$NakeWorkingDirectory$\");    //        are automatically created by Nake\n\nvar root = \"$NakeScriptDirectory$\"; //   this is how you can get script directory inlined\nWrite(Location.NakeScriptDirectory) //   alternatively call this method from Nake.Utility\n\nWrite(\"{{esc}}\");                   //  will simply print {esc} (no string interpolation)\nWrite(\"$$esc$$\");                   //  will simply print $esc$ (no env variable inlining)\n\nCmd($\"docker build -f {spec} .\");   //        you can use Shell.Cmd to execute \nCmd($\"echo {title}\");               //         commands via shell interpreter ...\n\nr = await Run($\"docker images\");    //      and you can get the result of the execution\nWrite(result.StandardOutput);       //    by using functionality provided by MedallionShell\n\nRun(\"app\") \u003c new FileInfo(\"input\")  //   this includes fancy composable piping and redirects\n\nawait $\"docker rm {cid} .\";         //      or simply await the cli string to get it executed\n                                    //    this is the the most convenient way to execute commands\n\nawait $@\"docker logs --tail 10 \\    //      backslash (\\) as line continuation symbol\n         {container}\";              //        could be used with verbatim strings\n\nawait \"app 'quoted arg'\"            //   use ' quote for arguments that contain spaces\nawait \"app 'quoted '' quote'\"       //       '' quote to insert a single quote\n\nawait $\"app '{path}'\"               //   you may quote interpolations that may contain space\nawait $\"app {path}\"                 //     but Nake will do it automatically for you ;)\nawait $\"app {arg}\\\\;;;\"             //   and MedallionShell will properly escape the arguments\n\nclass Azure                         //  namespace declarations cannot be used with scripts,\n{                                   //  but could be easily emulated with class declarations\n    class Queue                     //     and you can nest them infinitely as you like\n    {    \n        [Task] void Clean()         //     then from the command line you would invoke\n        {}                          //   this task by its class path (ie, azure queue clean)\n    }\n}\n\n[Nake] void Default() =\u003e Build();   //          running Nake without any options \n                                    //       will cause it to run the \"default\" task\n```\n\n## Command line reference\n\nGeneral syntax is: `Nake [options ...]  [VAR=VALUE ...]  [task ...]`\n\n```cs\n\u003e Nake -f \"Nake.csx\" Log=1 build    //       set Log environment variable to 1 and\n                                    //      then run Build() task from Nake.csx file \n                                        \n\u003e Nake Log=1 build                  //  equivalent to the above as Nake will automatically try \n                                    //   to use Nake.csx file if present in current directory\n```\n\nOptions:\n\n\t   -?  --help             Display help message and exit\n\t   -v  --version          Display the program version and exit\n\t   -q  --quiet            Do not echo informational messages to standard output\n\t   -s  --silent           Same as --quiet but also suppresses user generated log messages\n\t   -f  --nakefile FILE    Use FILE as Nake project file\n\t   -d  --directory DIR    Use DIR as current directory\n\t   -t  --trace            Enables full stack traces in error reporting + task execution trace\n\t       --debug            Enables full script debugging in Visual Studio\n\t   -T  --tasks [PATTERN]  Display tasks with descriptions matching optional PATTERN and exit\n\t   -r  --reset-cache      Resets compilation output cache\n\n### Invoking tasks\n\nGeneral syntax for invoking tasks and passing arguments is similar to the normal C# method invocation syntax, except ` ` is used instead of `,` to separate task arguments, and `=` is used instead of `:` for specifying named argument values. Also, boolean arguments support special `--` switch syntax.\n\n```cs\n\u003e Nake build                          //  run Build task with default arg values\n\u003e Nake build Release                  //  or with first positional argument set to 'Release'\n\u003e Nake build cfg=Release              //  or with named argument 'cfg' set to 'Release'\n\u003e Nake build Release outDir=\"/c/Tmp\"  //  you can mix positional and named arguments\n\u003e Nake build ; test                   //  or invoke multiple tasks within a same session\n\u003e Nake build `; test                  //  also escape ';' when running in PowerShell console \n\u003e Nake publish --beta                 //  invoke Publish task with 'beta' arg set to 'true'\n```\n\n## Included utility reference\n\nOut-of-the box Nake includes a lot of useful convinient utility functions to help you with: \n\n- running external tools, such as command-line commands or MSBuild\n- selecting and transforming file system paths (globber)\n- casual file system tasks, such as copying, moving, deleting files/folders \n- logging messages to console\n- working with environment variables\n- controlling Nake's runner\n- etc\n\nCheck out table below for reference on using utility library:\n\n| Class         \t\t\t\t\t\t                    | Functions     \t\t\t\t\t |\n|:----------------------------------------------------------|:------------------------------------------------------|\n| [Shell](https://github.com/yevhen/Nake/wiki/Shell)          \t| Executing programs and shell commands             |\n| [Session](https://github.com/yevhen/Nake/wiki/Session)       \t| Controlling current Nake's runner session         |\n| [Log](https://github.com/yevhen/Nake/wiki/Log)          \t| Logging messages to console                       |\n| [Env](https://github.com/yevhen/Nake/wiki/Env)          \t| Working with environment variables                |\n| [FS](https://github.com/yevhen/Nake/wiki/FS)            \t| File-system tasks, such as copy/move/del/mkdir/etc|\n| [FileSet](https://github.com/yevhen/Nake/wiki/FileSet)  \t| File path selection and transformation (globber)  |\n| [Color](https://github.com/yevhen/Nake/wiki/Color)      \t| Printing to console in color                      |\n| [Location](https://github.com/yevhen/Nake/wiki/Location)\t| Current directory and special paths (working, startup) |\n\nAlso, see 'by use-case' reference on [wiki](https://github.com/yevhen/Nake/wiki).\n\n## Tips \u0026 tricks\n\n```cs\nclass Azure\n{                                       \n    StorageAccount account;\n    \n    static Azure()                  //  this will run once before any of the \n    {                               //  tasks in this namespace are executed\n        account = Init();           //  (useful for one-off initialization)\n    }\n}  \n```\n\n## Backlog\n\n- Check the open issues\n\n## Contributing\n\nMake sure you follow the coding guidelines which exists on a project (either as R# formatting settings or .editorconfig). Nothing else)\n\n## Samples and Documentation\n\nHave a look at [Nake.csx](https://github.com/yevhen/Nake/blob/master/Nake.csx). It's a Nake file used to build and publish Nake itself (ye, we're eating our own dog food).\n\n## Community\n\nGeneral discussion group could be found [here](https://gitter.im/yevhen/Nake). Also, for news you can follow Nake's [official](https://twitter.com/NakeTool) twitter account (or [my](https://twitter.com/yevhen) account for that matter). The twitter's hashtag is `#naketool`.\n\n## Credits\n- Thanks to everyone in the Roslyn compiler team for making this happen\n- Thanks to everyone in the dotnet-script team\n- Thanks to MedallionShell community for the great project\n- Special thanks to Anton Martynenko for giving me an idea and steering Nake's DSL in the right direction\n- Hugs and kisses to my lovely Valery for being so patient and supportive, and for feeding me food and beer, while I was sitting in my cage working on Nake, instead of spending that time with her\n\n## License\n\nApache 2 License\n","funding_links":[],"categories":["Build Automation","自动构建"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyevhen%2FNake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyevhen%2FNake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyevhen%2FNake/lists"}