forked from PowerShell/platyPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
55 lines (46 loc) · 1.8 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
# script to create the final package in out\platyPS
param(
[ValidateSet('Debug', 'Release')]
$Configuration = "Debug",
[switch]$SkipDocs
)
# build .dll
# msbuild is part of .NET Framework, we can try to get it from well-known location.
if (-not (Get-Command -Name msbuild -ErrorAction Ignore)) {
Write-Warning "Appending probable msbuild path"
$env:path += ";${env:SystemRoot}\Microsoft.Net\Framework\v4.0.30319"
}
msbuild Markdown.MAML.sln /p:Configuration=$Configuration
$assemblyPath = (Resolve-Path "src\Markdown.MAML\bin\$Configuration\Markdown.MAML.dll").Path
# copy artifacts
mkdir out -ErrorAction SilentlyContinue > $null
cp -Rec -Force src\platyPS out
if (-not (Test-Path out\platyPS\Markdown.MAML.dll) -or
(ls out\platyPS\Markdown.MAML.dll).LastWriteTime -lt (ls $assemblyPath).LastWriteTime)
{
cp $assemblyPath out\platyPS
} else {
Write-Host -Foreground Yellow 'Skip Markdown.MAML.dll copying'
}
# copy schema file and docs
cp .\platyPS.schema.md out\platyPS
mkdir out\platyPS\docs -ErrorAction SilentlyContinue > $null
cp .\docs\* out\platyPS\docs\
# copy template files
mkdir out\platyPS\templates -ErrorAction SilentlyContinue > $null
cp .\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
}