forked from PowerShell/platyPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
86 lines (72 loc) · 2.42 KB
/
build.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<#
.SYNOPSIS
Builds the MarkDown/MAML DLL and assembles the final package in out\platyPS.
#>
[CmdletBinding()]
param(
[ValidateSet('Debug', 'Release')]
$Configuration = "Debug",
[switch]$SkipDocs,
[string]$DotnetCli
)
function Find-DotnetCli()
{
[string] $DotnetCli = ''
$dotnetCmd = Get-Command dotnet
return $dotnetCmd.Path
}
if (-not $DotnetCli) {
$DotnetCli = Find-DotnetCli
}
if (-not $DotnetCli) {
throw "dotnet cli is not found in PATH, install it from https://docs.microsoft.com/en-us/dotnet/core/tools"
} else {
Write-Host "Using dotnet from $DotnetCli"
}
if (Get-Variable -Name IsCoreClr -ValueOnly -ErrorAction SilentlyContinue) {
$framework = 'netstandard1.6'
} else {
$framework = 'net451'
}
& $DotnetCli publish ./src/Markdown.MAML -f $framework --output=$pwd/publish /p:Configuration=$Configuration
$assemblyPaths = (
(Resolve-Path "publish/Markdown.MAML.dll").Path,
(Resolve-Path "publish/YamlDotNet.dll").Path
)
# copy artifacts
New-Item -Type Directory out -ErrorAction SilentlyContinue > $null
Copy-Item -Rec -Force src\platyPS out
foreach($assemblyPath in $assemblyPaths)
{
$assemblyFileName = [System.IO.Path]::GetFileName($assemblyPath)
$outputPath = "out\platyPS\$assemblyFileName"
if ((-not (Test-Path $outputPath)) -or
(Test-Path $outputPath -OlderThan (Get-ChildItem $assemblyPath).LastWriteTime))
{
Copy-Item $assemblyPath out\platyPS
} else {
Write-Host -Foreground Yellow "Skip $assemblyFileName copying"
}
}
# copy schema file and docs
Copy-Item .\platyPS.schema.md out\platyPS
New-Item -Type Directory out\platyPS\docs -ErrorAction SilentlyContinue > $null
Copy-Item .\docs\* out\platyPS\docs\
# copy template files
New-Item -Type Directory out\platyPS\templates -ErrorAction SilentlyContinue > $null
Copy-Item .\templates\* out\platyPS\templates\
# put the right module version
if ($env:APPVEYOR_REPO_TAG_NAME)
{
$manifest = cat -raw out\platyPS\platyPS.psd1
$manifest = $manifest -replace "ModuleVersion = '0.0.1'", "ModuleVersion = '$($env:APPVEYOR_REPO_TAG_NAME)'"
Set-Content -Value $manifest -Path out\platyPS\platyPS.psd1 -Encoding Ascii
}
# dogfooding: generate help for the module
Remove-Module platyPS -ErrorAction SilentlyContinue
Import-Module $pwd\out\platyPS
if (-not $SkipDocs) {
New-ExternalHelp docs -OutputPath out\platyPS\en-US -Force
# reload module, to apply generated help
Import-Module $pwd\out\platyPS -Force
}