Giter Site home page Giter Site logo

yevhen / nake Goto Github PK

View Code? Open in Web Editor NEW
225.0 20.0 22.0 33.57 MB

Magic script-based C# task runner for .NET Core

License: Other

C# 99.95% Batchfile 0.03% Shell 0.02%
c-sharp script runner task automation developer-tools build dotnet dotnet-core shell

nake's Issues

Sample script scaffolding

Introduce special command to create sample Nake script and omnisharp.json file to have VSCode intellisense support.

  • It should be possible to specify sample script name.
  • Do not overwrite existing files (warn)

Multi-level caching

Currently, the project behind the script is re-generated and restore is initiated on every change to the script, despite that none of the dependencies were actually changed. Align the behavior with dotnet-script by introducing similar multi-level caching (dependencies + script code).

how to debug a nake script (csx file) in visual studio

Hi Yevhen,

I trust you are well!
Could you please suggest is there a way to debug a nake script in visual studio?
There doesn't seem to be any info available on this in net.

Any info would be mach appreciated.
Thanks in advance.

PS:
There is some link how to debug csx files with scriptcs.exe:
https://github.com/scriptcs/scriptcs/wiki/Debugging-a-script
but it doesn't seem to be helpful with nake scripts, when you don't even have scriptcs.exe on your PC, but have nake package, and using nake.exe instead of scriptcs.exe as per this instruction doesn't seem to be helpful.

Array arguments

Support tasks which have (params string[] args) parameters. Could be supplied as comma-separated list from the command line

Include some batteries

The shared theme with existing task runners is to provide some kind of utility library to help with the common file system operations, like mirroring directories. Think about including some of the most important into Nake.Utility package.

Automatic quotation of interpolations

Since the actual values that will be inlined from interpolations are opaque, to get rid of possible misinterpretation of values that may contain spaces, the interpolations need to be quoted, e.g. await $"app '{path}'".

It would be super-cool if we can do the automatic quotation of interpolated expressions when such strings are the input to await or Shell.Run.

Concerns:

  • Interpolations which area already quoted
  • Interpolations which reside inside quotes, e.g. await $"app 'some {path} arg with spaces'"
  • Interpolations which reside between quotes, e.g. await $"app 'arg1' {path} 'arg2'"
  • How to determine if interpolation should be quoted for a particular invocation (e.g. call to Shell.Run)?

Running on .NET Core

In principle, it should be relatively easy to run Nake on Mono using Xamarin's version of Roslyn, but Utility library requires more serious effort. In order to have faster TTM, Utility library was built on top of MSBuild, so a lot of built-in functions such as those in FS class need to be rewritten using only .NET apis.

Similar situation is with MSBuild function. Mono uses it's own XBuild engine, to build .NET projects. It's compatible with MSBuild project format and possibility of hosting it within Nake (like MSBuild) need to be investigated. Or layer of indirection should be created.

For the rest, some minor stuff which uses native Win32 calls should be done with conditional compilation. For the whole list, MOMA could be used.

Print task argument documentation to console

Nake supports printing information about all available tasks to console via dotnet nake -T switch. This prints task name and description, which is parsed from method's xml documentation (either F# style or normal <summmary> tag). It would be cool to support more detailed task listing which also includes descriptions of task arguments.

The argument documentation may come from standard xml documentation of the task method. The user may invoke printing of detailed task description by passing --help switch after task name: dotnet build --help. If task has declared boolean argument of this name, the automatic printing is suppressed and task is called with help=true. This will allow users to override default behavior to print their own help.

FS.RemoveDir does not handle exclusion pattern for files

I've followed this example from Nake.csx:

RemoveDir(@"**\bin|**\obj|{path}\*|-:*.vshost.exe");    

Expecting that folders containing *.vshost.exe files (presumably locked by VS) would not be removed.
However Nake tries to remove them according to this message:

Removing directory "C:\projects\..\someproj\bin".
MSBUILD : error MSB3231: Unable to remove directory "C:\projects\..\someproj\bin". Access to the path SomeProj.vshost.exe' is denied.
Microsoft.Build.Tasks.RemoveDir failed

Probably such exclusion for files should not be used with RemoveDir, as it is not really consistent with FileSet exclusion semantics. But on the other hand, such exclusion looks very handy. So I'm not sure whether it worth it to fix behavior. Or it's better to fix Nake.csx instead :)

Other possible approach could be adding a standard ContinueOnError msbuild parameter to the RemoveDir extension.

Asking for missing arguments

In PowerShell, when you run Cmdlet and don't supply all required parameters, it will ask to provide value for each missing argument. Should be relatively easy to have something similar in Nake.

Fix wiki documentation for Shell

  • Complete documentation for Shell.Cmd
  • Complete documentation for Shell.Run
  • Samples for piping and redirects
  • Samples for using Tee class
  • Document await-ing strings
  • Document argument escaping in commands
  • Document backslash for line continuations

Stepping back from this project - help wanted

Hello, all!

This was first OSS project and I'm still think it's one of the best task runners 'by design', but my life is changing in a way that I won't have enough spare time working on that. You might have already noticed that I haven't touched anything here for a year or so. Which is not a good situation for an OSS project.

If you feel like this project is useful to you and you want to progress it further, or/and would be willing to take custodianship of NuGet publishing and project admin rights, please email me privately - [email protected] (or DM on twitter to @yevhen).

Thanks,
Hope for the best,
Yevhen

Nested tasks cli invocation syntax

Change current cli invocation syntax for calling nested tasks (the tasks defined within a class) to use spaces (e.g. dotnet tool list) instead of dots (dotnet.tool list)

Update to .NET 7

Hi,

I upgrade all my app to .NET7 since few weeks.
Do you plan to update Nake to support this last major version ?

Thanks

Any updates ?

Hi,

I was looking for a C# build automation tool :

  • Cake : interesting but limited to a defined subset of C# provided by API ref.
  • Nuke : does not support scripting, not what i wante.

Then i discovered Nake, and it fits all my needs :

  • base on script (csx file)
  • support C# and many cool feature (nuget...)

But 18 month since the last commit, app is in beta 2 and does not run in .NET5.
So what's problem : lack of contributors or app contains to many bugs ?

Thanks

Empty Nake.csx fails to run with 3.0.0-beta-02 due to NuGet resolution errors

I created an empty Nake.csx just to give Nake a try. Attempting to run dotnet tool run nake (version 3.0.0-beta-01) gives:

Unable to restore packages from 'C:\Users\alex\AppData\Local\Temp\scripts\C\Users\alex\source\repos\tests\netcoreapp3.1\script.csproj'. Make sure that all script files contains valid NuGet references

The contents of that file are:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <LangVersion>latest</LangVersion>
  </PropertyGroup>
  <ItemGroup></ItemGroup>
  <Target Name="RecordReferencePaths" AfterTargets="AfterResolveReferences">
    <WriteLinesToFile File="$(OutputPath)/ReferencePaths.txt" Lines="@(ReferencePath)" />
  </Target>
</Project>

Running with --trace gives:

Creating project file for *.csx files found in C:\Users\alex\source\repos\tests using netcoreapp3.1 as the default framework.
Parsing C:\Users\alex\source\repos\tests\Nake.csx
Project file saved to C:\Users\alex\AppData\Local\Temp\scripts\C\Users\alex\source\repos\tests\netcoreapp3.1\script.csproj
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <LangVersion>latest</LangVersion>
  </PropertyGroup>
  <ItemGroup></ItemGroup>
  <Target Name="RecordReferencePaths" AfterTargets="AfterResolveReferences">
    <WriteLinesToFile File="$(OutputPath)/ReferencePaths.txt" Lines="@(ReferencePath)" />
  </Target>
</Project>
Computing compilation dependencies
Creating project file for *.csx files found in C:\Users\alex\source\repos\tests using netcoreapp3.1 as the default framework.
Parsing C:\Users\alex\source\repos\tests\Nake.csx
Project file saved to C:\Users\alex\AppData\Local\Temp\scripts\C\Users\alex\source\repos\tests\netcoreapp3.1\script.csproj
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <LangVersion>latest</LangVersion>
  </PropertyGroup>
  <ItemGroup></ItemGroup>
  <Target Name="RecordReferencePaths" AfterTargets="AfterResolveReferences">
    <WriteLinesToFile File="$(OutputPath)/ReferencePaths.txt" Lines="@(ReferencePath)" />
  </Target>
</Project>
Restoring C:\Users\alex\AppData\Local\Temp\scripts\C\Users\alex\source\repos\tests\netcoreapp3.1\script.csproj using the dotnet cli. RuntimeIdentifier : win10-x64 NugetConfigFile: C:\Users\alex\source\repos\tests\NuGet.Config
Executing 'dotnet restore "C:\Users\alex\AppData\Local\Temp\scripts\C\Users\alex\source\repos\tests\netcoreapp3.1\script.csproj" -r win10-x64  --configfile "C:\Users\alex\source\repos\tests\NuGet.Config"'
  Determining projects to restore...
C:\Users\alex\AppData\Local\Temp\scripts\C\Users\alex\source\repos\tests\netcoreapp3.1\script.csproj : error NU1100: Unable to resolve 'Microsoft.NETCore.App.Runtime.win-x64 (= 3.1.7)' for '.NETCoreApp,Version=v3.1'.
C:\Users\alex\AppData\Local\Temp\scripts\C\Users\alex\source\repos\tests\netcoreapp3.1\script.csproj : error NU1100: Unable to resolve 'Microsoft.WindowsDesktop.App.Runtime.win-x64 (= 3.1.7)' for '.NETCoreApp,Version=v3.1'.
C:\Users\alex\AppData\Local\Temp\scripts\C\Users\alex\source\repos\tests\netcoreapp3.1\script.csproj : error NU1100: Unable to resolve 'Microsoft.AspNetCore.App.Runtime.win-x64 (= 3.1.7)' for '.NETCoreApp,Version=v3.1'.
  Failed to restore C:\Users\alex\AppData\Local\Temp\scripts\C\Users\alex\source\repos\tests\netcoreapp3.1\script.csproj (in 148 ms).
Unable to restore packages from 'C:\Users\alex\AppData\Local\Temp\scripts\C\Users\alex\source\repos\tests\netcoreapp3.1\script.csproj'. Make sure that all script files contains valid NuGet references
   at Dotnet.Script.DependencyModel.Context.DotnetRestorer.Restore(ProjectFileInfo projectFileInfo, String[] packageSources)
   at Dotnet.Script.DependencyModel.Context.ProfiledRestorer.Restore(ProjectFileInfo projectFileInfo, String[] packageSources)
   at Dotnet.Script.DependencyModel.Compilation.CompilationDependencyResolver.GetDependencies(String targetDirectory, IEnumerable`1 scriptFiles, Boolean enableScriptNugetReferences, String defaultTargetFramework)
   at Nake.Scripting.Script.CompilationDependencies(ScriptSource source) in C:\Work\OSS\Nake\Source\Nake\Scripting\Script.cs:line 108
   at Nake.Scripting.Script.Compile(ScriptSource source, AssemblyReference[] dependencies) in C:\Work\OSS\Nake\Source\Nake\Scripting\Script.cs:line 70
   at Nake.BuildEngine.Compile(ScriptSource source, AssemblyReference[] dependencies) in C:\Work\OSS\Nake\Source\Nake\Build.cs:line 68
   at Nake.BuildEngine.Build(BuildInput input) in C:\Work\OSS\Nake\Source\Nake\Build.cs:line 54
   at Nake.CachingBuildEngine.Build(BuildInput input) in C:\Work\OSS\Nake\Source\Nake\Caching.cs:line 59
   at Nake.Application.Build(ScriptSource source, IEnumerable`1 declarations) in C:\Work\OSS\Nake\Source\Nake\Application.cs:line 105
   at Nake.Application.Invoke(ScriptSource source, IEnumerable`1 declarations)
   at Nake.Application.Start() in C:\Work\OSS\Nake\Source\Nake\Application.cs:line 54
   at Nake.Program.StartApplication(String[] args) in C:\Work\OSS\Nake\Source\Nake\Program.cs:line 55
   at Nake.Program.Main(String[] args) in C:\Work\OSS\Nake\Source\Nake\Program.cs:line 19
   at Nake.Program.<Main>(String[] args)

... which isn't terribly helpful either, as far as I can tell.

In case it matters, my dotnet --info is:

.NET Core SDK (reflecting any global.json):
 Version:   3.1.401
 Commit:    5b6f5e5005

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.401\

Host (useful for support):
  Version: 5.0.0-preview.7.20364.11
  Commit:  53976d38b1

.NET SDKs installed:
  2.1.802 [C:\Program Files\dotnet\sdk]
  3.0.100 [C:\Program Files\dotnet\sdk]
  3.1.102 [C:\Program Files\dotnet\sdk]
  3.1.201 [C:\Program Files\dotnet\sdk]
  3.1.202 [C:\Program Files\dotnet\sdk]
  3.1.401 [C:\Program Files\dotnet\sdk]
  5.0.100-preview.7.20366.6 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.7.20365.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.7.20364.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0-preview.7.20366.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

I wonder if there's some kind of issue caused by the fact that I'm using .NET 5? I wouldn't think so since tools are supposed to run with the .NET Core version they're built for, and I do have .NET Core 3 installed as well...

Patch assemblies with build version

Currently, the assembly file version is not updated for package release. Since caching is dependent on the version of Nake this may break it.

Orphan nake.bat and nake.csx files after opening VS

Given following project structure:

project
|_src
| |_packages
| | |_Nake.2.3.1
| |_project.sln
| 
|_nake.bat
|_nake.csx

Whenever I open project.sln in Visual Studio, two sample Nake files nake.bat and nake.csx are created inside src folder. Which is not desired behavior - since I have my nake files already in a parent folder.

Analysis

That's init.ps1 script who copies sample nake files. According to Nuget docs it's executed every time when solution is opened in VS.

Spaces in directory confuses params passed to MSBuild

MSBUILD : error MSB1008: Only one project can be specified.
Switch: Samples\Orleankka\Output;ReferencePath=C:\Users\a\Code

For switch syntax, type "MSBuild /help"
Process exited with code 1

Actual directory name was "Code Samples"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.