nightroman / Invoke-Build

Build Automation in PowerShell

Home Page:https://github.com/nightroman/Invoke-Build/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request: add BuildName var

majkinetor opened this issue · comments

How about adding $BuildName to be equal to

$BuildName = (Split-Path -Leaf $BuildFile).Replace('.build.ps1','')

I have this on every Enter-Build in monorepo. Its handy because in services that use multiple build.ps1 files you can report it, such as:

task Run {
    start 'cmd.exe' -ArgumentList "/D /C title $BuildName & dotnet run $run_options"
}

It saves a line of boilerplate.

I think exposing $BuildFile is enough. Then users do whatever they want with it. For example your "boilerplate" line and extraction of "build name". (NB Which is not quite right because build files do not have to follow *.build.ps1 convention, *.ps1 is enough. Also it is OK to name the script just .build.ps1 = empty build name??).

"Build name" is something opinionated. E.g. I never need it. But if I need it I would rather just do: $BuildName = "foo bar". It does not have to depend on the script name.

Closing. I am sorry if this disappoints you. We cannot add features just because they are useful sometimes for some users. There must be more reasons. By the way, I have a few my own "boilerplates" in my scripts. They are not added to IB, even though I could, indeed :)

I am sorry if this disappoints you.

Not at all m8. This is legit answer and we may differ on opinion.

Given that mainstream powershell is now cross-platform, I thought .build.ps1 should be explicitelly deprecated due to linux side effects and this could be catched and warned during BuildName construction.

"Build name" is something opinionated. E.g. I never need it. But if I need it I would rather just do: $BuildName = "foo bar". It does not have to depend on the script name.

I could say exactly the same for BuildFile - I can't remember I ever used it. Contrary, I usually have at least 5 build files per service, one for each sub-service, so you would support monorepo paradigm (showing BuildFile has a lot more info then needed , i.e. its noise) .

I am glad that you are not disappointed :)

Given that mainstream powershell is now cross-platform, I thought .build.ps1
should be explicitelly deprecated due to linux side effects and this could be
catched and warned during BuildName construction.

I mentioned this consideration in wiki.
But I am not explicitly deprecating this. It's up to a user after all.
Personally, most of my scripts are .build.ps1, I am a strictly Windows
developer.

Interestingly, a user may even use the "hidden" build script feature
effectively. I find such use cases possible (but I do not have them).