forked from jbogard/bulk-writer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpsake-build-helpers.ps1
39 lines (34 loc) · 1.04 KB
/
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
34
35
36
37
38
39
function Set-Project-Properties($version) {
write-host "$version"
set-regenerated-file "$pwd/Directory.Build.props" @"
<Project>
<PropertyGroup>
<Version>$version</Version>
<Copyright>$(get-copyright)</Copyright>
</PropertyGroup>
</Project>
"@
}
function Get-Copyright {
$date = Get-Date
$year = $date.Year
$copyrightSpan = if ($year -eq $yearInitiated) { $year } else { "$yearInitiated-$year" }
return [char]0x00A9 + " $copyrightSpan $owner"
}
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
}
}