-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.ps1
More file actions
63 lines (48 loc) · 2.32 KB
/
package.ps1
File metadata and controls
63 lines (48 loc) · 2.32 KB
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
[CmdletBinding()]
param (
[string]$sourcePath = "src",
[string]$configuration = "Release",
[string]$artifactsPath = "artifacts"
)
process {
$azureSourceDirectory = "$sourcePath\Azure"
$gitversionFile = ".git\gitversion_cache\*.yml"
$azureArtifactsDirectory = "$artifactsPath\Azure"
$azureToolsModule = "$azureArtifactsDirectory\Azure-Tools.psm1"
$azureFunctionsArtfiactsPath = "$artifactsPath\Functions"
$artifactsPath, $azureFunctionsArtfiactsPath | Foreach-Object {
if (-Not (Test-Path -Path $_)) {
New-Item -Type Directory -Path $_ -Force | Out-Null
}
else {
Write-Verbose "Cleaning $artifactsPath"
Remove-Item -Force -Recurse -Path "$artifactsPath\*"
}
}
if (Test-Path -Path $gitversionFile) {
Write-Verbose "Copying $gitversionFile to $artifactsPath\version.txt"
Copy-Item $gitversionFile -Destination "$artifactsPath\version.txt"
}
else {
Write-Verbose "No $gitversionFile found"
}
Copy-Item -Force -Recurse -Path "$sourcePath\DnzHost\bin\$configuration\net461\*" -Destination $azureFunctionsArtfiactsPath
# Build Azure PowerShell Tooling
if (Test-Path -Path $azureSourceDirectory) {
Write-Verbose "Build Azure Tools for Release Management"
New-Item -ItemType Directory -Path $azureArtifactsDirectory -Force -ErrorAction Ignore | Out-Null
$modules = @()
Get-ChildItem $azureSourceDirectory -Filter "*.ps1" | ForEach-Object {
Add-Content -Encoding Ascii -Path $azureToolsModule -Value (Get-Content -Raw $_.FullName)
$modules += $_.BaseName
Write-Verbose " - added $($_.BaseName) to the module collection"
}
Add-Content -Encoding Ascii -Path $azureToolsModule -Value "Export-ModuleMember -Function $($modules -join `",`")"
}
# Copy Azure Resource Management Templates
if (Test-Path -Path $azureSourceDirectory) {
Write-Verbose "Copy Azure Resource Management Templates to $($azureArtifactsDirectory)"
New-Item -ItemType Directory -Path $azureArtifactsDirectory -Force -ErrorAction Ignore | Out-Null
Copy-Item -Force -Recurse -Path "$azureSourceDirectory\*.json" -Destination $azureArtifactsDirectory
}
}