-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Tasks/Bootstrap sample, amend related
- Loading branch information
1 parent
17ae0f5
commit cb70d5d
Showing
12 changed files
with
119 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
task Direct { | ||
($r = .\Project.build.ps1 Build -Configuration Release) | ||
assert ($r -contains 'Building Release') | ||
} | ||
|
||
task Engine { | ||
($r = Invoke-Build Build -Configuration Release) | ||
assert ($r -contains 'Building Release') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<# | ||
.Synopsis | ||
Directly invocable build script with Invoke-Build bootstrapping. | ||
.Example | ||
PS> ./Project.build.ps1 Build | ||
This command invokes the task Build defined in this script. | ||
If Invoke-Build is not available, its module is installed. | ||
Then Invoke-Build is called. | ||
.Example | ||
PS> Invoke-Build Build | ||
This command may be used when Invoke-Build is available. | ||
#> | ||
|
||
param( | ||
[Parameter(Position=0)] | ||
$Tasks | ||
, | ||
[ValidateSet('Debug', 'Release')] | ||
[string]$Configuration = 'Release' | ||
) | ||
|
||
# bootstrap | ||
if (!$MyInvocation.ScriptName.EndsWith('Invoke-Build.ps1')) { | ||
$ErrorActionPreference = 1 | ||
if (!(Get-Command Invoke-Build -ErrorAction 0)) { | ||
Write-Host 'Installing module InvokeBuild...' | ||
Install-Module InvokeBuild -Scope CurrentUser -Force | ||
Import-Module InvokeBuild | ||
} | ||
return Invoke-Build $Tasks $MyInvocation.MyCommand.Path @PSBoundParameters | ||
} | ||
|
||
# Synopsis: Build project. | ||
task Build { | ||
"Building $Configuration" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Build script with Invoke-Build bootstrapping | ||
|
||
In addition to being directly invokable, see [Direct](../Direct), build scripts | ||
may automatically check for the availability of the command `Invoke-Build` and | ||
install its module when needed | ||
|
||
```powershell | ||
param( | ||
[Parameter(Position=0)] | ||
[string[]]$Tasks, | ||
#... other script parameters | ||
) | ||
# bootstrap | ||
if (!$MyInvocation.ScriptName.EndsWith('Invoke-Build.ps1')) { | ||
$ErrorActionPreference = 1 | ||
if (!(Get-Command Invoke-Build -ErrorAction 0)) { | ||
Write-Host 'Installing module InvokeBuild...' | ||
Install-Module InvokeBuild -Scope CurrentUser -Force | ||
Import-Module InvokeBuild | ||
} | ||
return Invoke-Build $Tasks $MyInvocation.MyCommand.Path @PSBoundParameters | ||
} | ||
# the usual build script | ||
task ... | ||
``` | ||
|
||
See [Project.build.ps1](Project.build.ps1) for the working example. | ||
|
||
See [Direct](../Direct) for some more details about direct calls. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
|
||
task Direct { | ||
($r = .\my.build.ps1 t1, t2 -Param1 bar -Param2 42) | ||
($r = .\Project.build.ps1 t1, t2 -Param1 bar -Param2 42) | ||
assert ($r -contains 'Param1 = bar') | ||
assert ($r -contains 'Param2 = 42') | ||
} | ||
|
||
task Engine { | ||
($r = Invoke-Build t1, t2 my.build.ps1 -Param1 bar -Param2 42) | ||
($r = Invoke-Build t1, t2 -Param1 bar -Param2 42) | ||
assert ($r -contains 'Param1 = bar') | ||
assert ($r -contains 'Param2 = 42') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.paket | ||
packages | ||
paket-files | ||
paket.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
source https://api.nuget.org/v3/index.json | ||
|
||
storage: none | ||
framework: netcoreapp3.1, netstandard2.0, netstandard2.1 | ||
|
||
nuget Invoke-Build storage: packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters