Skip to content

Commit

Permalink
Updated documentation with some bootstrap usage examples, referenced …
Browse files Browse the repository at this point in the history
…psake-config.ps1, added 128x128 icon, added sample build.ps1 for shipping in the nuget package
  • Loading branch information
Iristyle committed Jul 16, 2012
1 parent aa65753 commit bfd3328
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 9 deletions.
97 changes: 88 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,90 @@ A set of Powershell modules for sweetening [Psake](https://github.com/psake/psak

Enhances Psake with some commonly needed functionality when using a build server
such as Jenkins. Useful not only for any build or continuous delivery system,
but also could be useful in other scenarios where PowerShell scripts are used
for maintenance.
but also in other scenarios where PowerShell scripts are used for maintenance.

Using with Psake
====

These modules may be imported by modifing the `psake-config.ps1` and adding
something like

```powershell
$config.modules=(".\packages\Midori\tools\*.psm1")
```

A standard `build.ps1` (included in the tools directory for convenience) that
bootstraps VsVars32.bat, Nuget and Psake looks like:

```powershell
function Get-Batchfile ($file)
{
$cmd = "`"$file`" & set"
cmd /c $cmd | % {
$p, $v = $_.split('=')
Set-Item -path env:$p -value $v
}
}
function VsVars32($version = "10.0")
{
$key = if ([intptr]::size -eq 8)
{ "HKLM:SOFTWARE\Wow6432Node\Microsoft\VisualStudio\" + $version }
else
{ "HKLM:SOFTWARE\Microsoft\VisualStudio\" + $version }
$VsKey = Get-ItemProperty $key
$VsInstallPath = [IO.Path]::GetDirectoryName($VsKey.InstallDir)
$VsToolsDir = Join-Path ([IO.Path]::GetDirectoryName($VsInstallPath)) 'Tools'
$BatchFile = Join-Path $VsToolsDir 'vsvars32.bat'
Get-Batchfile $BatchFile
}
function Get-CurrentDirectory
{
$thisName = $MyInvocation.MyCommand.Name
[IO.Path]::GetDirectoryName((Get-Content function:$thisName).File)
}
Set-Location (Get-CurrentDirectory)
VsVars32
if (Test-Path 'nuget.exe')
{
&.\nuget update -Self
}
else
{
$nugetPath = Join-Path (Get-CurrentDirectory) 'nuget.exe'
(New-Object Net.WebClient).DownloadFile('http://nuget.org/NuGet.exe', $nugetPath)
}
[Environment]::SetEnvironmentVariable("EnableNuGetPackageRestore","true")
$buildPackageDir = Join-Path (Get-CurrentDirectory) 'packages'
$sourcePackageDir = Join-Path (Get-CurrentDirectory) '..\src\Packages'
@(@{Id = 'psake'; Version='4.2.0.1'; Dir = $buildPackageDir; NoVersion = $true },
@{Id = 'Midori'; Version='0.1.0.0'; Dir = $buildPackageDir; NoVersion = $true },
@{Id = 'DotNetZip'; Version='1.9.1.8'; Dir = $buildPackageDir; NoVersion = $true }) |
% {
$versionSwitch = if ($_.NoVersion) {'-ExcludeVersion'} else { '' }
&.\nuget install "$($_.Id)" -v "$($_.Version)" -o `""$($_.Dir)"`" "$versionSwitch"
}
Remove-Module psake -erroraction silentlycontinue
Import-Module (Join-Path $buildPackageDir 'psake\tools\psake.psm1')
$host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size(512,80)
Invoke-psake default
```

Included Modules
====


* BuildTools - A set of helpers for common build related tasks
* `Invoke-AuthenticodeSignTool` - Will find signtool.exe based on common locations
and will exeucte it.
* `New-ZipFile` - Will create or add to an existing zip file with the given
* `New-ZipFile` - Will create or add to an existing zip file with the given
list of files, and can re-root the paths. Depends on DotNetZip (not included),
but easy enough to restore with Nuget
* Files
Expand All @@ -25,7 +98,7 @@ Included Modules
info to a given chat room, including specifying colors, etc.
* Jenkins
* `Get-JenkinsS3Build` - Will use a Jenkins job name and either a specific
integer build id or will use the REST api and a given build result, to
integer build id or will use the REST api and a given build result, to
download the build assets from S3. Relies on the S3 plugin being installed
in Jenkins.
* Powershell-Contrib - A number of miscellaneous PowerShell helpers.
Expand All @@ -43,7 +116,7 @@ Included Modules
support in the current host.
* `Test-Transcribing` - A means of checking to see if the host is currently
in the process of transcribing.
* `Remove-Error` - Will clear the last X number of errors from the given
* `Remove-Error` - Will clear the last X number of errors from the given
$Error object. By default will clear from $global:Error
* `Start-TempFileTranscriptSafe` - Will start transcribing the current host if
it is possible, and will return the temp file name of the transcript file.
Expand All @@ -59,7 +132,7 @@ Included Modules
* `Export-ModuleToSession` - Will take modules out of the current session and
try to push them to the remote session. This has a number of caveats,
including being able to find the psm1 files on disk -- if the simple
resolution process fails, this won't work. Prefer to use
resolution process fails, this won't work. Prefer to use
Export-SourceModuleToSession.
* `Export-SourceModuleToSession` - This is the magic I could come up with for
sharing modules across the wire. The local module files are copied to the
Expand All @@ -81,7 +154,7 @@ setting up integration tests or similar.
Future Improvements
===

Next in the pipeline -
Next in the pipeline -

* Fleshing out Pester tests in a few spots where applicable - some things are
quite difficult to test easily since they are dependent on external systems
Expand Down Expand Up @@ -109,9 +182,15 @@ ification of everything, and the various details around targets and their
outputs, you end up with something that no one else on your team can understand.
Builds have a much better mapping to procedural code, and Psake brings sanity to
the .NET world.
* For the icon,
* The icon was derived from the Creative Commons image by David Peters [here](http://commons.wikimedia.org/wiki/File:Cocktail-icon.svg)

Contributions
===

If you see something wrong,
If you see something wrong, feel free to submit a pull request.
Coding guidelines are :

- Indent with 2 spaces
- 80 character lines
- All cmdlets should have documentation, including all their parameters
- 72 character lines for documentation
Binary file added logo-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions tools/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
function Get-Batchfile ($file)
{
$cmd = "`"$file`" & set"
cmd /c $cmd | % {
$p, $v = $_.split('=')
Set-Item -path env:$p -value $v
}
}

function VsVars32($version = '10.0')
{
$key = if ([intptr]::size -eq 8)
{ "HKLM:SOFTWARE\Wow6432Node\Microsoft\VisualStudio\$version" }
else
{ "HKLM:SOFTWARE\Microsoft\VisualStudio\$version" }

$VsKey = Get-ItemProperty $key
$VsInstallPath = [IO.Path]::GetDirectoryName($VsKey.InstallDir)
$VsToolsDir = Join-Path ([IO.Path]::GetDirectoryName($VsInstallPath)) 'Tools'
$BatchFile = Join-Path $VsToolsDir 'vsvars32.bat'
Get-Batchfile $BatchFile
}

function Get-CurrentDirectory
{
$thisName = $MyInvocation.MyCommand.Name
[IO.Path]::GetDirectoryName((Get-Content function:$thisName).File)
}

Set-Location (Get-CurrentDirectory)

VsVars32
if (Test-Path 'nuget.exe')
{
&.\nuget update -Self
}
else
{
$nugetPath = Join-Path (Get-CurrentDirectory) 'nuget.exe'
(New-Object Net.WebClient).DownloadFile('http://nuget.org/NuGet.exe', $nugetPath)
}

[Environment]::SetEnvironmentVariable('EnableNuGetPackageRestore','true')
$buildPackageDir = Join-Path (Get-CurrentDirectory) 'packages'
$sourcePackageDir = Join-Path (Get-CurrentDirectory) '..\src\Packages'

@(@{Id = 'psake'; Version='4.2.0.1'; Dir = $buildPackageDir; NoVersion = $true },
@{Id = 'Midori'; Version='0.1.0.0'; Dir = $buildPackageDir; NoVersion = $true },
@{Id = 'DotNetZip'; Version='1.9.1.8'; Dir = $buildPackageDir; NoVersion = $true }) |
% {
$versionSwitch = if ($_.NoVersion) {'-ExcludeVersion'} else { '' }
&.\nuget install "$($_.Id)" -v "$($_.Version)" -o `""$($_.Dir)"`" "$versionSwitch"
}

Remove-Module psake -erroraction silentlycontinue
Import-Module (Join-Path $buildPackageDir 'psake\tools\psake.psm1')
$host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size(512,80)
Invoke-psake default

0 comments on commit bfd3328

Please sign in to comment.