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

Idea: Make Invoke-Build available as dotnet new template (mostly slated towards f#).

da9l opened this issue · comments

This is how it could be done:

https://bitbucket.org/da9l/invokebuildtemplate/src/master/

It's pretty unpolished especially the bootstrap functions but to test it,

clone repo

.\template.build.ps1 InstallLocally #installs template from local folder into local dotnetsdk template library

md mytestproject | cd
dotnet new console -lang f#
dotnet new invokebuild
.\mytestproject.build.ps1

.\mytestproject.build.ps1 #to build project.

This can be done on any machine with just dotnetsdk installed. (have only tested on windows with powershell 7)

Thank you for the interesting idea and the sample of using it.
I did not think of using dotnet new for bootstrapping, yet.

Feel free to use it or follow up with ideas on how I could rewrite it as a PR to your repo.
The doubts I have is around the bootstrapping and the dependency to paket. As a F# dev I use paket but it´s not a given for C# dev.

In a template you could add a parameter that tells if it should use default nuget solution or paket.
I'm just unsure/haven't given it much thought how one would in-place bootstrap Invoke-Build using the default dotnet nuget.

Please do not go for a PR or similar moves yet. The idea is promising but there is so much to think about. It is very difficult to get bootstrapping and/or scaffolding right, so that it suites at least many users ("majority" is not realistic, IMHO). Everybody has it's own way of using and getting IB, I believe.

Yeah, I figured that much. I realized too that this idea is not quite ready for PR yet. I do however think this could get pretty close to a pit of success for many both F# and C# projects and in my experience, ease of getting started often win the day. The added support for gitversion might or might not be a good thing.

Generally I really prefer the idea of each dotnet new template being functionally speaking - composable. You should be able to add it where ever you are in your project creating process.

Thanks for your feedback!

I have doubts that the template should be designed for paket or nuget in the first place. In PowerShell world packages are delivered by PowerShellGet (Install-Module). paket is good, no doubts. But I believe many PowerShell and IB users do not use it.

PowerShellGet (Install-Module) based template does not require anything but PowerShell, given it comes with PowerShellGet nowadays. This does not exclude use of packet or nuget, but it's up to a user. The template takes care of just InvokeBuild.

Fair enough. PowerShellGet should probably be the default to resolve the invokebuild dependency as long as it can be done as non-intrusively as possible for a dotnet project in the dotnet new template. My whish here is that if a CI server have access either directly to nuget.org, powershellgallery.com a dev setting up a project should not have to do anything but installing the template and configuring the script. I.E. no or close to no CI-server configuration.

If that can be achieved I guess I'm fine with any solution.

Regards, Daniel

OK, let's start with something. Here is the temp (?) repository https://github.com/nightroman/Invoke-Build.template
See its root build script for available tasks/actions.

It makes/installs ib-basic template. It is a self-invoking build script with automatic bootstrapping of InvokeBuild module, with a pinned version.

Later on we may add some ib-paket, for example.
(dotnet template packages may contain more than one template, just in case).

Please review the latest changes in the temp (?) repository https://github.com/nightroman/Invoke-Build.template
See the README for options.

I am not going to engage any dotnet tools in the IB template.
The reasons are described below.

The following commands are for creating a project, not for building it:

dotnet new tool-manifest
dotnet tool install paket
dotnet tool install ...
dotnet paket init
...

In other words, when you clone/have a "real" project, commands like above are not needed.
They were already invoked in the past and resulted in the project files like:

.config/dotnet-tools.json
paket.dependencies
...

These commands are for building a project:

dotnet tool restore
dotnet restore
dotnet build
...

I engaged some of them, e.g. restore and build in various flavours depending on options.

Tools are not mentioned in the template. But adding dotnet tool restore to the restore task manually, for example, is not a big deal. After all, the generated template is not the final build script. It must be reviewed, adjusted, evolved manually.

And it is on nuget.org -- https://www.nuget.org/packages/Invoke-Build.template/
Also added links to README and Wiki.
I am closing the issue as resolved.

@da9l You are welcome to give your feedback here or open issues in the new repository.
(for now I would like to have this template developed in its own repository)