lholman / OneBuild

Convention based PowerShell build for .NET http://lholman.github.io/OneBuild/
Apache License 2.0
17 stars 2 forks source link

Tips on .build.ps1 #1

Closed nightroman closed 10 years ago

nightroman commented 10 years ago

I was just passing by and noticed that you use Invoke-Build. I am glad to see this. May I recommend something in order to improve .build.ps1 a little bit?


You may remove

$ErrorActionPreference = 'Stop'

because this is done by Invoke-Build.


You may remove

$basePath = Resolve-Path .

and use the special Invoke-Build variable $BuildRoot instead of $basePath.


The line

Write-Output "Base module path: $baseModulePath"

causes a warning because Invoke-Build discourages output from the script scope. You may either remove this line or use Write-Host instead of Write-Output. Write-Host has disadvantages but it is used in two tasks anyway. If this is important to avoid Write-Host then use this code

function Enter-Build {
    Write-Output "Base module path: $baseModulePath"
}

This function is called on every build before any task and writes output without a warning.


You may reformat your task comments so that #* Purpose: is replaced with # Synopsis:. As a result, the command

Invoke-Build ?

will show the task synopsis column populated with your comments (one line though).


Happy building!

lholman commented 10 years ago

@nightroman Thank you ever so much for taking the time look through my integration with Invoke-Build, I'll make those changes you suggest above as a PR and send you a link to take and verify if that's ok?

nightroman commented 10 years ago

I can make a PR with these changes, give me a day or two.

lholman commented 10 years ago

@nightroman Wow, that would be fantastic, I'll hold fire for now then. Thanks again

nightroman commented 10 years ago

Please review the PR. In addition to the list above:

All changes are completely up to you.