Last active
October 18, 2018 15:31
-
-
Save AlbertoDePena/a4708a707821b8c894847b4f4d11b6a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param | |
( | |
[String] | |
$OutputDirectory = $(Throw "The output directory was not specified."), | |
[String] | |
$PackDirectory = $(Throw "The pack directory was not specified.") | |
) | |
try { | |
Write-Output "Packaging azure functions..." | |
Write-Output "Output directory: $OutputDirectory" | |
Write-Output "Pack directory: $PackDirectory" | |
if (!(Test-Path $OutputDirectory)) { | |
Throw "$OutputDirectory directory does not exist." | |
} | |
if (!(Test-Path $PackDirectory)) { | |
Throw "$PackDirectory directory does not exist." | |
} | |
$functionsDirectory = "$PackDirectory\Functions" | |
New-Item -ItemType Directory -Force -Path "$functionsDirectory" | |
if (!(Test-Path "$functionsDirectory\host.json")) { | |
"{}" | Out-File -FilePath "$functionsDirectory\host.json" | |
} | |
Get-ChildItem "$OutputDirectory" -Recurse -Filter function.json | | |
Foreach-Object { | |
$dllDirectory = $_.Directory.Parent.FullName | |
$functionName = $_.Directory.Name | |
$functionJsonFile = $_.FullName | |
$binDirectory = "$functionsDirectory\$functionName\bin" | |
New-Item -ItemType Directory -Force -Path "$binDirectory" | |
Copy-Item $functionJsonFile "$functionsDirectory\$functionName" | |
Copy-Item "$dllDirectory\*.dll" $binDirectory -Force | |
Copy-Item "$dllDirectory\*.config" $binDirectory -Force | |
Copy-Item "$dllDirectory\$functionName\*.fsx" "$functionsDirectory\$functionName" -Force | |
} | |
$exitCode = 0 | |
} | |
catch { | |
Write-Error "*** $_" | |
$exitCode = 1 | |
} | |
finally { | |
Exit $exitCode | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment