Skip to content

Commit

Permalink
Minor tweaks, new demo Repeat2
Browse files Browse the repository at this point in the history
  • Loading branch information
nightroman committed Mar 1, 2024
1 parent 072ca3e commit f8502cc
Show file tree
Hide file tree
Showing 25 changed files with 264 additions and 94 deletions.
16 changes: 11 additions & 5 deletions Build-Checkpoint.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,23 @@ specific language governing permissions and limitations under the License.
#.ExternalHelp InvokeBuild-Help.xml
[CmdletBinding(DefaultParameterSetName='Default')]
param(
[Parameter(Position=0, Mandatory=1)][string]$Checkpoint,
[Parameter(Position=1)][hashtable]$Build,
[switch]$Preserve,
[Parameter(Position=0, Mandatory=1)]
[string]$Checkpoint
,
[Parameter(Position=1)]
[hashtable]$Build
,
[switch]$Preserve
,
[Parameter(ParameterSetName='Resume', Mandatory=1)]
[switch]$Resume,
[switch]$Resume
,
[Parameter(ParameterSetName='Auto', Mandatory=1)]
[switch]$Auto
)

$ErrorActionPreference = 1
try {
$ErrorActionPreference = 'Stop'

$Checkpoint = $PSCmdlet.GetUnresolvedProviderPathFromPSPath($Checkpoint)

Expand Down
12 changes: 8 additions & 4 deletions Build-JustTask.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@
#>

param(
[Parameter(Position=0, Mandatory=1)][string[]]$Task,
[Parameter(Position=1)]$File,
[switch]$Safe,
[Parameter(Position=0, Mandatory=1)]
[string[]]$Task
,
[Parameter(Position=1)]$File
,
[switch]$Safe
,
[switch]$Summary
)

$ErrorActionPreference = 'Stop'
$ErrorActionPreference = 1
try {
${*data} = @{
Task = $Task
Expand Down
19 changes: 13 additions & 6 deletions Build-Parallel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,22 @@ specific language governing permissions and limitations under the License.

#.ExternalHelp InvokeBuild-Help.xml
param(
[Parameter(Position=0)][hashtable[]]$Build,
$Result,
[int]$Timeout=[int]::MaxValue,
[int]$MaximumBuilds=[Environment]::ProcessorCount,
[switch]$FailHard,
[Parameter(Position=0)]
[hashtable[]]$Build
,
[object]$Result
,
[int]$Timeout=[int]::MaxValue
,
[int]$MaximumBuilds=[Environment]::ProcessorCount
,
[switch]$FailHard
,
[string[]]$ShowParameter
)

$ErrorActionPreference = 1

# info, result
$info = [PSCustomObject]@{
Tasks = [System.Collections.Generic.List[object]]@()
Expand All @@ -44,7 +52,6 @@ if (!$Build) {return}
# get and source the engine
$ib = Join-Path (Split-Path $MyInvocation.MyCommand.Path) Invoke-Build.ps1
try {. $ib} catch {$PSCmdlet.ThrowTerminatingError($_)}
$ErrorActionPreference = 'Stop'

### make works, check scripts
$works = @()
Expand Down
4 changes: 2 additions & 2 deletions Convert-psake.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ param(
)

trap {$PSCmdlet.ThrowTerminatingError($_)}
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
$ErrorActionPreference = 1
Set-StrictMode -Version 3

### Source

Expand Down
2 changes: 1 addition & 1 deletion Invoke-Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ function Write-Warning([Parameter()]$Message) {
${*}.Warnings.Add([PSCustomObject]@{Message = $Message; File = $BuildFile; Task = ${*}.Task; InvocationInfo=$MyInvocation})
}

$ErrorActionPreference = 'Stop'
$ErrorActionPreference = 1
foreach($_ in ${*}.DP.get_Values()) {
if ($_.IsSet) {
${*}.SP[$_.Name] = $_.Value
Expand Down
2 changes: 1 addition & 1 deletion Invoke-TaskFromISE.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ param(
[switch]$Console
)

$ErrorActionPreference = 'Stop'
$ErrorActionPreference = 1

$private:ib = "$(Split-Path $MyInvocation.MyCommand.Path)\Invoke-Build.ps1"
if (!(Test-Path -LiteralPath $ib)) {
Expand Down
3 changes: 2 additions & 1 deletion Invoke-TaskFromVSCode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ param(
[Parameter()]
[switch]$Console
)

$ErrorActionPreference = 1
try {
$ErrorActionPreference = 'Stop'

$private:file = $null
try {
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2011-2023 Roman Kuzmin
Copyright (c) 2011-2024 Roman Kuzmin

Apache License
Version 2.0, January 2004
Expand Down
71 changes: 31 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

[![NuGet](https://buildstats.info/nuget/Invoke-Build)](https://www.nuget.org/packages/Invoke-Build)
[![PSGallery](https://img.shields.io/powershellgallery/dt/InvokeBuild.svg)](https://www.powershellgallery.com/packages/InvokeBuild)
[![NuGet](https://buildstats.info/nuget/Invoke-Build)](https://www.nuget.org/packages/Invoke-Build)
<img src="https://raw.githubusercontent.com/nightroman/Invoke-Build/main/ib.png" align="right"/>

## Build Automation in PowerShell
Expand All @@ -27,44 +27,43 @@ Several *PowerShell Team* projects use Invoke-Build.

The package includes the engine, helpers, and help:

* [Invoke-Build.ps1](Invoke-Build.ps1) - invokes build scripts, this is the build engine
* [Build-Checkpoint.ps1](Build-Checkpoint.ps1) - invokes persistent builds using the engine
* [Build-Parallel.ps1](Build-Parallel.ps1) - invokes parallel builds using the engine
* [Resolve-MSBuild.ps1](Resolve-MSBuild.ps1) - finds the specified or latest MSBuild
* [Show-TaskHelp.ps1](Show-TaskHelp.ps1) - shows task help, used on WhatIf calls
* [Invoke-Build.ps1](https://github.com/nightroman/Invoke-Build/blob/main/Invoke-Build.ps1) - invokes build scripts, this is the build engine
* [Build-Checkpoint.ps1](https://github.com/nightroman/Invoke-Build/blob/main/Build-Checkpoint.ps1) - invokes persistent builds using the engine
* [Build-Parallel.ps1](https://github.com/nightroman/Invoke-Build/blob/main/Build-Parallel.ps1) - invokes parallel builds using the engine
* [Resolve-MSBuild.ps1](https://github.com/nightroman/Invoke-Build/blob/main/Resolve-MSBuild.ps1) - finds the specified or latest MSBuild
* [Show-TaskHelp.ps1](https://github.com/nightroman/Invoke-Build/blob/main/Show-TaskHelp.ps1) - shows task help, used on WhatIf calls
* *about_InvokeBuild.help.txt* - module help file
* *InvokeBuild-Help.xml* - content for Get-Help

Extra tools, see PSGallery and the repository:
Extra scripts, see PSGallery and the repository:

* [Invoke-Build.ArgumentCompleters.ps1](Invoke-Build.ArgumentCompleters.ps1) - completers for v5 native, TabExpansion2.ps1
* [Invoke-TaskFromVSCode.ps1](Invoke-TaskFromVSCode.ps1) - invokes a task from a build script opened in VSCode
* [New-VSCodeTask.ps1](New-VSCodeTask.ps1) - generates VSCode tasks bound to build script tasks
* [Invoke-TaskFromISE.ps1](Invoke-TaskFromISE.ps1) - invokes a task from a script opened in ISE
* [Invoke-Build.ArgumentCompleters](https://www.powershellgallery.com/packages/Invoke-Build.ArgumentCompleters) - completers for v5 native, TabExpansion2.ps1
* [Invoke-TaskFromVSCode](https://www.powershellgallery.com/packages/Invoke-TaskFromVSCode) - invokes a task from a build script opened in VSCode
* [Show-BuildGraph](https://www.powershellgallery.com/packages/Show-BuildGraph) - shows task graph by Graphviz Viz.js or dot
* [New-VSCodeTask](https://www.powershellgallery.com/packages/New-VSCodeTask) - generates VSCode tasks bound to build script tasks
* [Invoke-TaskFromISE](https://www.powershellgallery.com/packages/Invoke-TaskFromISE) - invokes a task from a script opened in ISE

And some more tools, see the repository:

* [ib.cmd](ib.cmd), [ib.sh](ib.sh) - cmd and bash helpers
* [Build-JustTask.ps1](Build-JustTask.ps1) - invokes tasks without references
* [Convert-psake.ps1](Convert-psake.ps1) - converts psake build scripts, see [wiki](https://github.com/nightroman/Invoke-Build/wiki/Convert~psake)
* [Show-BuildTree.ps1](Show-BuildTree.ps1) - shows task trees as text
* [Show-BuildDgml.ps1](Show-BuildDgml.ps1) - shows task graph as DGML
* [Show-BuildGraph.ps1](Show-BuildGraph.ps1) - shows task graph by Graphviz
* [Show-BuildMermaid.ps1](Show-BuildMermaid.ps1) - shows task graph by Mermaid
* [ib.cmd](https://github.com/nightroman/Invoke-Build/blob/main/ib.cmd), [ib.sh](https://github.com/nightroman/Invoke-Build/blob/main/ib.sh) - cmd and bash helpers
* [Build-JustTask.ps1](https://github.com/nightroman/Invoke-Build/blob/main/Build-JustTask.ps1) - invokes tasks without references
* [Convert-psake.ps1](https://github.com/nightroman/Invoke-Build/blob/main/Convert-psake.ps1) - converts psake build scripts, see [wiki](https://github.com/nightroman/Invoke-Build/wiki/Convert~psake)
* [Show-BuildTree.ps1](https://github.com/nightroman/Invoke-Build/blob/main/Show-BuildTree.ps1) - shows task trees as text
* [Show-BuildDgml.ps1](https://github.com/nightroman/Invoke-Build/blob/main/Show-BuildDgml.ps1) - shows task graph as DGML
* [Show-BuildMermaid.ps1](https://github.com/nightroman/Invoke-Build/blob/main/Show-BuildMermaid.ps1) - shows task graph by Mermaid

## Install as module

Invoke-Build is published as PSGallery module [InvokeBuild](https://www.powershellgallery.com/packages/InvokeBuild).
You can install it by one of these commands:

Install-Module InvokeBuild -Scope CurrentUser
Install-Module InvokeBuild

To install the module with Chocolatey, run the following command:

choco install invoke-build

> NOTE: The Chocolatey package is maintained by its owner.
NOTE: The Chocolatey package is maintained by its owner.

## Install as scripts

Expand All @@ -79,12 +78,12 @@ path. You may need to start a new PowerShell session with the updated path.

Otherwise, download the package manually, rename it to zip, extract its *tools*
and rename to *InvokeBuild*. Consider including this directory to the path for
invoking scripts by names. Or copy to the PowerShell module directory in order
to use it as the module.
invoking scripts by names. Or copy to any PowerShell module directory in order
to use it as module.

## Install as dotnet tool

[nuget.org/packages/ib](https://www.nuget.org/packages/ib/) provides Invoke-Build
[nuget.org/packages/ib](https://www.nuget.org/packages/ib) provides Invoke-Build
as the dotnet tool `ib` which may be installed as global or local.

To install the global tool:
Expand All @@ -96,7 +95,7 @@ To install the local tool:
dotnet new tool-manifest # once on setting up a repo with tools
dotnet tool install --local ib

> See [ib/README](ib/README.md) for more details about `ib` commands.
See [ib/README](https://github.com/nightroman/Invoke-Build/blob/main/ib/README.md) for more details about `ib` commands.

## Getting help

Expand All @@ -119,22 +118,14 @@ In order to get help for internal commands:

## Online resources

- [Basic Concepts](https://github.com/nightroman/Invoke-Build/wiki/Concepts)
: Why build scripts may have advantages over normal scripts.
- [Script Tutorial](https://github.com/nightroman/Invoke-Build/wiki/Script-Tutorial)
: Take a look in order to get familiar with build scripts.
- [Step by Step Tutorial](https://github.com/nightroman/Invoke-Build/tree/main/Tasks/01-step-by-step-tutorial)
: From "Hello world" to featured scripts.
- [Invoke-Build.template](https://github.com/nightroman/Invoke-Build.template)
: Create scripts by `dotnet new ib`.
- [Project Wiki](https://github.com/nightroman/Invoke-Build/wiki)
: Detailed tutorials, helpers, notes, and etc.
- [Examples](https://github.com/nightroman/Invoke-Build/wiki/Build-Scripts-in-Projects)
: Build scripts used in various projects.
- [Tasks](https://github.com/nightroman/Invoke-Build/tree/main/Tasks)
: Samples, patterns, and various techniques.
- [Design Notes](https://github.com/nightroman/Invoke-Build/wiki/Design-Notes)
: Technical details for contributors.
- [Basic Concepts](https://github.com/nightroman/Invoke-Build/wiki/Concepts): Why build scripts may have advantages over normal scripts.
- [Script Tutorial](https://github.com/nightroman/Invoke-Build/wiki/Script-Tutorial): Take a look in order to get familiar with build scripts.
- [Step by Step Tutorial](https://github.com/nightroman/Invoke-Build/tree/main/Tasks/01-step-by-step-tutorial): From "Hello world" to featured scripts.
- [Invoke-Build.template](https://github.com/nightroman/Invoke-Build.template): Create scripts by `dotnet new ib`.
- [Project Wiki](https://github.com/nightroman/Invoke-Build/wiki): Detailed tutorials, helpers, notes, and etc.
- [Examples](https://github.com/nightroman/Invoke-Build/wiki/Build-Scripts-in-Projects): Build scripts used in various projects.
- [Tasks](https://github.com/nightroman/Invoke-Build/tree/main/Tasks): Samples, patterns, and various techniques.
- [Design Notes](https://github.com/nightroman/Invoke-Build/wiki/Design-Notes): Technical details for contributors.
- [Release Notes](https://github.com/nightroman/Invoke-Build/blob/main/Release-Notes.md)

[discussions]: https://github.com/nightroman/Invoke-Build/discussions
Expand Down
5 changes: 5 additions & 0 deletions Release-Notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Invoke-Build Release Notes

## v5.10.6

Minor tweaks, new demo Tasks/Repeat2, etc.

`Show-BuildGraph.ps1`
- available at PSGallery
- uses `Viz.js` by default and `dot` with `-Dot`
- shows node and edge tooltips (synopses, names)

Expand Down
4 changes: 4 additions & 0 deletions Show-BuildDgml.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@
.Parameter File
See: help Invoke-Build -Parameter File
.Parameter Output
The output file and the format specified by its extension.
The default is "$env:TEMP\name-xxxxxxxx.dgml".
.Parameter Parameters
Build script parameters needed in special cases when they alter tasks.
.Parameter NoShow
Tells to create the output file without showing it.
In this case Output is normally specified by a caller.
.Parameter Number
Tells to show job numbers on edges connecting tasks.
Expand Down
10 changes: 10 additions & 0 deletions Show-BuildGraph.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<#PSScriptInfo
.VERSION 1.0.0
.AUTHOR Roman Kuzmin
.COPYRIGHT (c) Roman Kuzmin
.TAGS Invoke-Build, Graphviz
.GUID 43d94ab6-d0c5-4c6a-839d-2ace0449bf56
.LICENSEURI http://www.apache.org/licenses/LICENSE-2.0
.PROJECTURI https://github.com/nightroman/Invoke-Build
#>

<#
.Synopsis
Shows Invoke-Build task graph using Graphviz Viz.js or dot.
Expand Down
20 changes: 14 additions & 6 deletions Show-BuildTree.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@
Task names.
If it is "*" then all root tasks are used.
If it is omitted or "." then the default task is used.
.Parameter File
The build script.
If it is omitted then the default script is used.
.Parameter Parameters
Build script parameters needed in special cases when they alter tasks.
.Parameter Upstream
Tells to show upstream tasks for each task.
.Inputs
None.
.Outputs
Specified task trees.
Expand All @@ -29,12 +30,20 @@
#>

param(
[Parameter(Position=0)][string[]]$Task,
[Parameter(Position=1)][string]$File,
[Parameter(Position=2)][hashtable]$Parameters,
[Parameter(Position=0)]
[string[]]$Task
,
[Parameter(Position=1)]
[string]$File
,
[Parameter(Position=2)]
[hashtable]$Parameters
,
[switch]$Upstream
)

$ErrorActionPreference = 1

$private:_Task = $Task
$private:_File = $File
$private:_Parameters = if ($Parameters) {$Parameters} else {@{}}
Expand Down Expand Up @@ -76,7 +85,6 @@ function ShowTaskTree($Task, $Docs, $Step = 0) {
}
}

$ErrorActionPreference = 'Stop'
try {
. Invoke-Build

Expand Down
12 changes: 9 additions & 3 deletions Show-TaskHelp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@
.Parameter Task
Build task name(s). The default is the usual default task.
.Parameter File
Build script path. The default is the usual default script.
.Parameter NoCode
Tells to skip code analysis for parameters and environment.
It is used as true for PowerShell v2.
.Parameter Format
Specifies the custom task help formatter.
Expand All @@ -45,9 +48,12 @@
#>

param(
[Parameter(Position=0)][string[]]$Task,
[Parameter(Position=1)]$File,
$Format = 'Format-TaskHelp',
[Parameter(Position=0)][string[]]$Task
,
[Parameter(Position=1)]$File
,
[object]$Format = 'Format-TaskHelp'
,
[switch]$NoCode
)

Expand Down
Loading

0 comments on commit f8502cc

Please sign in to comment.