-
Notifications
You must be signed in to change notification settings - Fork 302
/
psake-build-helpers.ps1
33 lines (29 loc) · 981 Bytes
/
psake-build-helpers.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function Get-Copyright {
$date = Get-Date
$year = $date.Year
$copyrightSpan = if ($year -eq $yearInitiated) { $year } else { "$yearInitiated-$year" }
return "© $copyrightSpan $owner"
}
function Publish-Project {
$project = Split-Path $pwd -Leaf
Write-Host "Publishing $project"
dotnet publish --configuration $configuration --no-build --output $publish/$project /nologo
}
function Set-Regenerated-File($path, $newContent) {
if (-not (test-path $path -PathType Leaf)) {
$oldContent = $null
} else {
$oldContent = [IO.File]::ReadAllText($path)
}
if ($newContent -ne $oldContent) {
write-host "Generating $path"
[System.IO.File]::WriteAllText($path, $newContent, [System.Text.Encoding]::UTF8)
}
}
function Remove-Directory-Silently($path) {
if (test-path $path) {
write-host "Deleting $path"
Remove-Item $path -recurse -force -ErrorAction SilentlyContinue | out-null
}
}