Closed sayedihashimi closed 9 years ago
I've used the functions below on several projects where psbuild is used. It would be easier to add this to the psbuild.psm1 directly.
psbuild.psm1
Note: we should investigate if the names of the functions below are what we want to use
function Filter-String{ [cmdletbinding()] param( [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)] [string[]]$message ) process{ foreach($msg in $message){ if($nugetApiKey){ $msg = $msg.Replace($nugetApiKey,'REMOVED-FROM-LOG') } $msg } } } function Write-Message{ [cmdletbinding()] param( [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)] [string[]]$message ) process{ Filter-String -message $message | Write-Verbose } } <# .SYNOPSIS If nuget is in the tools folder then it will be downloaded there. #> function Get-Nuget{ [cmdletbinding()] param( $toolsDir = ("$env:LOCALAPPDATA\LigerShark\tools\"), $nugetDownloadUrl = 'http://nuget.org/nuget.exe' ) process{ $nugetDestPath = Join-Path -Path $toolsDir -ChildPath nuget.exe if(!(Test-Path $nugetDestPath)){ $nugetDir = ([System.IO.Path]::GetDirectoryName($nugetDestPath)) if(!(Test-Path $nugetDir)){ New-Item -Path $nugetDir -ItemType Directory | Out-Null } 'Downloading nuget.exe' | Write-Message (New-Object System.Net.WebClient).DownloadFile($nugetDownloadUrl, $nugetDestPath) # double check that is was written to disk if(!(Test-Path $nugetDestPath)){ throw 'unable to download nuget' } } # return the path of the file $nugetDestPath } }
Get-FilteredString was added a while back and Get-NuGet is available because nuget-powershell is imported.
Get-FilteredString
Get-NuGet
I've used the functions below on several projects where psbuild is used. It would be easier to add this to the
psbuild.psm1
directly.Note: we should investigate if the names of the functions below are what we want to use