Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc

# Numerous always-ignore extensions
###################
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.vi
*~

*.sass-cache
# Folders to ignore
###################
.hg
.svn
.CVS
# OS or Editor folders
###################
.DS_Store
Icon?
Thumbs.db
ehthumbs.db
nbproject
.cache
.project
.settings
.tmproj
*.esproj
*.sublime-project
*.sublime-workspace
# Dreamweaver added files
###################
_notes
dwsync.xml
# Komodo
###################
*.komodoproject
.komodotools
6 changes: 3 additions & 3 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ psake-contrib is a repository for scripts, modules and functions that are useful

## How to get started:

**Step 1:** Download the project zip file
**Step 1:** Download the project zip file

**Step 2:** CD into the directory where you downloaded the zip
**Step 2:** CD into the directory where you downloaded the zip

You will need to "unblock" the zip file before extracting - PowerShell by default does not run files downloaded from the internet.
Just right-click the zip and click on "properties" and click on the "unblock" button.

**Step 3:** Extract the files in the zip

**Step 4:** Use the scripts and modules in your build
**Step 4:** Use the scripts and modules in your build

The following is an excellent technet article on how to ["dot source"](http://technet.microsoft.com/en-us/library/ee176949.aspx) a script

Expand Down
24 changes: 12 additions & 12 deletions database.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ function Invoke-SqlCommand {
[cmdletbinding(DefaultParameterSetName='customauth')]
param(
[Parameter(Mandatory=$false)]
[string]
[string]
$sqlServer = ".\SQLEXPRESS",

[Parameter(Mandatory=$false)]
[string]
[string]
$database = "Northwind",
[Parameter(Mandatory=$true)]
[string]

[Parameter(Mandatory=$true)]
[string]
$sqlCommand,

[Parameter(Mandatory=$false, ParameterSetName='credauth')]
[System.Management.Automation.PsCredential]
[System.Management.Automation.PsCredential]
$credential,

[Parameter(Mandatory=$false, ParameterSetName='customauth')]
[string]
[string]
$authentication ="Integrated Security=SSPI;",

[Parameter(ParameterSetName='devauth')]
[switch]
$developmentAuthentication
)

switch ($PsCmdlet.ParameterSetName) {
switch ($PsCmdlet.ParameterSetName) {
'devauth' {
$authentication = 'User ID=sa;Password=pass'
Write-Debug "Using development authentication: $authentication"
Expand Down
22 changes: 11 additions & 11 deletions debugging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ Shows what tasks are called when Full task is specified during Invoke-Psake buil
Add-Type -path "$PSScriptRoot\lib\NodeXl\Microsoft.NodeXL.Layouts.dll"
Add-Type -path "$PSScriptRoot\lib\NodeXl\Microsoft.NodeXL.Util.dll"
Add-Type -path "$PSScriptRoot\lib\NodeXl\Microsoft.NodeXL.Visualization.Wpf.dll"

$c = New-Object Microsoft.NodeXL.Visualization.Wpf.NodeXlControl
$c.Layout = New-Object Microsoft.NodeXL.Layouts.SugiyamaLayout
#$c.Layout = New-Object Microsoft.NodeXL.Layouts.HarelKorenFastMultiscaleLayout
$c.BackColor = [System.Windows.Media.Color]::FromRgb(0xff, 0xff, 0xff)

function New-Vertex {
param($vertices, $name)
$v = $vertices.Add()
Expand All @@ -54,24 +54,24 @@ Shows what tasks are called when Full task is specified during Invoke-Psake buil
$v.SetValue([Microsoft.NodeXL.Core.ReservedMetadataKeys]::PerVertexLabelFillColor, [System.Drawing.Color]::White)
$v
}


function New-Edge {
param($edges, $vert1, $vert2)
$e = $edges.Add($vert1, $vert2, $true)
$e.SetValue([Microsoft.NodeXL.Core.ReservedMetadataKeys]::PerColor, [System.Drawing.Color]::Blue)
$e.SetValue([Microsoft.NodeXL.Core.ReservedMetadataKeys]::PerEdgeWidth, [single]3)
$e
}

function Get-TaskGraph {
$m = Import-Module $psakeModuleFile -pass
& $m {
& $m {
$script:dependencies = New-Object Collections.ArrayList

${function:Write-TaskTimeSummary} = {}
${function:Invoke-Task} = {
param($taskName)
param($taskName)
write-host Task $taskname
$taskKey = $taskName.ToLower()
$currentContext = $psake.context.Peek()
Expand All @@ -93,16 +93,16 @@ Shows what tasks are called when Full task is specified during Invoke-Psake buil
@($dependencies | Select-Object -ExpandProperty Parent) + @($dependencies | Select-Object -ExpandProperty DependsOn) |
Select-Object -unique |
% -begin { $vertices=@{}}`
-process {
-process {
Write-Debug "Adding vertex for $_"
$vertices[$_] = New-Vertex $c.Graph.Vertices $_
}

$dependencies | % {
Write-Debug "Adding edge for $_"
New-Edge $c.Graph.Edges $vertices[$_.Parent] $vertices[$_.DependsOn] > $null
}

$window = New-Object Windows.Window
$window.Title = "Invoke-Psake build visualizer"
$window.Content = $c
Expand Down
8 changes: 4 additions & 4 deletions io.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ function Set-WorkingDirectory {
.Synopsis
Allows to execute given scriptblock in different directory.
.Description
Allows to execute given scriptblock in different directory. It wraps
cmdlets that work with location. It changes the location to $Directory nad
Allows to execute given scriptblock in different directory. It wraps
cmdlets that work with location. It changes the location to $Directory nad
after the $code is executed, it changes the directory to original one.
.Example
Set-location c:\temp
Set-WorkingDirectory -dir c:\ -code { gci }
write-host Current directory: get-location

It performs gci in directory c:\
#>
param(
Expand All @@ -25,7 +25,7 @@ function Set-WorkingDirectory {
Push-Location
Set-Location $directory
try {
. $code
. $code
}
finally {
Pop-Location
Expand Down
24 changes: 12 additions & 12 deletions nunit.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ param(
$script:nunit = $nunitPath
Write-Host "Nunit path set to $nunitPath"

function nunit
function nunit
{
param(
[Parameter(Position=0,Mandatory=$true)]
Expand All @@ -28,20 +28,20 @@ function nunit
)
$tempFile = "$env:TEMP\psake-nunit.xml"
if (test-path $tempFile) { Get-Item $tempFile | Remove-Item } #Remove-Item $tempFile doesn't work because my temp is C:\Users\J34EF~1.STE\AppData\Local\Temp

$param = @()
if ($Include.Count -gt 0) { $param += '/include:'+($Include -join ',') }
if ($Exclude.Count -gt 0) { $param += '/exclude:'+($Exclude -join ',') }
if ($NoShadow) { $param += '/noshadow' }

Write-Debug "output xml file: $tempFile"
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
$output = & $nunit $assembly /nologo /xml:$tempFile @param
if (!$silent) {
$output | Out-Host
}
$stopwatch.stop()

$ret = new-Object PsObject -prop @{
Assembly = $assembly
Failed = $false
Expand All @@ -60,11 +60,11 @@ function nunit
$ret.Error = 'No output file was created'
return $ret
}
# when silent, normal output is not written, but then it is not clear what caused the error
# when silent, normal output is not written, but then it is not clear what caused the error
# so we will parse the xml and show the failing test
$res = [xml](gc $tempFile)
$failed = $res |
Select-Xml -XPath '//test-case' |
$failed = $res |
Select-Xml -XPath '//test-case' |
Select-Object -ExpandProperty Node |
? { $_.success -eq "false" } |
% { $ret.FailedTestCases += new-Object PsObject -prop @{
Expand All @@ -81,26 +81,26 @@ function nunit
$ret.Total = $res.Total
$ret.Failures = $res.Failures # should be 0
$ret.Errors = $res.Errors # should be 0
$ret.NotRun = $res.'Not-Run'
$ret.NotRun = $res.'Not-Run'
}
$ret
}

function Write-NunitRes
{
param([Parameter(Mandatory=$true)][PsObject]$res)

if ($res.Failed) {
Write-ScriptError "Some Nunit tests failed:"
$res.FailedTestCases |
$res.FailedTestCases |
% { Write-Host "------------------------------------"
Write-Host Name:`n $_.Name
Write-Host Name:`n $_.Name
Write-Host Statk trace:`n $_.StackTrace
Write-Host Message:`n $_.Messsage
Write-Host
}
}
Write-Host "Total: " $res.Total
Write-Host "Total: " $res.Total
Write-Host "Errors " $res.Errors
Write-Host "Failures " $res.Failures
Write-Host "NotRun: " $res.NotRun
Expand Down
22 changes: 11 additions & 11 deletions svn.psm1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# takes one parameter and somehow notifies user; It could be email, growl message, output to file...
# takes one parameter and somehow notifies user; It could be email, growl message, output to file...
[scriptblock]$script:Notifier = {}
# todo: read output from xml

function Set-SvnNotifier {
param(
param(
[Parameter(Mandatory=$true)][scriptblock]$notifier
)
$script:Notifier = $notifier
Expand All @@ -16,7 +16,7 @@ function Get-SvnInfo
)
$info = svn info $dir
$ret = new-object PSObject
$info | % {
$info | % {
if ($_ -match '^Revision') { $ret | Add-Member NoteProperty Revision ($_ -replace 'Revision[\s:]*','') }
if ($_ -match '^Last Changed Author') { $ret | Add-Member NoteProperty Author ($_ -replace 'Last Changed Author[\s:]*','') }
if ($_ -match '^Last Changed Date') { $ret | Add-Member NoteProperty Date ($_ -replace 'Last Changed Date[\s:]*','') }
Expand All @@ -28,15 +28,15 @@ function Update-Svn
{
param(
[Parameter(Mandatory=$true)][string]$dir,
[switch]$gui,
[switch]$gui,
[switch]$Wait
)
$info = Get-SvnInfo $dir
if ($gui) {
Start-Process TortoiseProc.exe -Argument "/command:update", "/path:`"$dir`"" -wait:$wait
} else {
svn update $dir |
% {
svn update $dir |
% {
$m = $_
switch -regex ($m) {
'^(Updated to|At revision)' { write-host $m }
Expand All @@ -58,7 +58,7 @@ function Update-Svn
$_.Info | % { write-host " $_" }
}
}
# more colors:
# more colors:
#"Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White" -split ', '|% { write-host $_ -fore $_ }
}

Expand All @@ -82,12 +82,12 @@ function Get-SvnLogInfos
$line = $_
switch -regex ($_) {
'^(-*|\s*)$' { return }
'^r\d+\s*\|\s*[\w\.]+\s\|' {
'^r\d+\s*\|\s*[\w\.]+\s\|' {
if ($header -ne $null) { $ret += $header }
$header = new-object PSObject -property @{Header = $line; Info = @() }
$header = new-object PSObject -property @{Header = $line; Info = @() }
}
default {
$header.Info += $line
default {
$header.Info += $line
}
}
}
Expand Down
Loading