-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdoBuild.ps1
74 lines (62 loc) · 3.08 KB
/
doBuild.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
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
<#
.DESCRIPTION
Implement build and packaging of the package and place the output $OutDirectory/$ModuleName
#>
function DoBuild
{
Write-Verbose -Verbose -Message "Starting DoBuild with configuration: $BuildConfiguration, framework: $BuildFramework"
# Module build out path
$BuildOutPath = "${OutDirectory}/${ModuleName}"
Write-Verbose -Verbose -Message "Module output file path: '$BuildOutPath'"
# Module build source path
$BuildSrcPath = "bin/${BuildConfiguration}/${BuildFramework}/publish"
Write-Verbose -Verbose -Message "Module build source path: '$BuildSrcPath'"
# Copy psd1 file
Write-Verbose -Verbose "Copy-Item ${SrcPath}/${ModuleName}.psd1 to $BuildOutPath"
Copy-Item "${SrcPath}/${ModuleName}.psd1" "$BuildOutPath"
# Copy help
Write-Verbose -Verbose -Message "Copying help files to '$BuildOutPath'"
copy-item -Recurse "${HelpPath}/${Culture}" "$BuildOutPath"
if ( Test-Path "${SrcPath}/code" ) {
Write-Verbose -Verbose -Message "Building assembly and copying to '$BuildOutPath'"
# build code and place it in the staging location
Push-Location "${SrcPath}/code"
try {
# Check dotnet version
Write-Verbose -Verbose -Message "DotNet version: $(dotnet --version)"
# Build source
Write-Verbose -Verbose -Message "Building with configuration: $BuildConfiguration, framework: $BuildFramework"
Write-Verbose -Verbose -Message "Building location: PSScriptRoot: $PSScriptRoot, PWD: $pwd"
dotnet publish --configuration $BuildConfiguration --framework $BuildFramework --output $BuildSrcPath
# Dump build source output directory
# $outResults = Get-ChildItem -Path "bin/${BuildConfiguration}/${BuildFramework}" -Recurse | Out-String
# Write-Verbose -Verbose -Message $outResults
# Place build results
if (! (Test-Path -Path "$BuildSrcPath/${ModuleName}.dll"))
{
throw "Expected binary was not created: $BuildSrcPath/${ModuleName}.dll"
}
Write-Verbose -Verbose -Message "Copying implementation assembly $BuildSrcPath/${ModuleName}.dll to $BuildOutPath"
Copy-Item "$BuildSrcPath/${ModuleName}.dll" -Dest "$BuildOutPath"
if (Test-Path -Path "$BuildSrcPath/${ModuleName}.pdb")
{
Write-Verbose -Verbose -Message "Copying implementation pdb $BuildSrcPath/${ModuleName}.pdb to $BuildOutPath"
Copy-Item -Path "$BuildSrcPath/${ModuleName}.pdb" -Dest "$BuildOutPath"
}
}
catch {
# Write-Error "dotnet build failed with error: $_"
Write-Verbose -Verbose -Message "dotnet build failed with error: $_"
}
finally {
Pop-Location
}
}
else {
Write-Verbose -Verbose -Message "No code to build in '${SrcPath}/code'"
}
## Add build and packaging here
Write-Verbose -Verbose -Message "Ending DoBuild"
}