-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Compress-SiteExtension.ps1 (#10793)
* Add Compress-SiteExtension.ps1 * Add log for copying JIT trace file * Add .jitmarker file
- Loading branch information
Showing
5 changed files
with
119 additions
and
7 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
src/WebJobs.Script.SiteExtension/Compress-SiteExtension.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<# | ||
.SYNOPSIS | ||
Compresses the site extension. | ||
.DESCRIPTION | ||
Takes in an unzipped site extension and produces a site extension. | ||
.PARAMETER InputPath | ||
The path of the unzipped 'SiteExtension'. Leave null to scan for root in a child from here. | ||
.PARAMETER OutputPath | ||
The path to produce the site extension to. Leave null to use current directory. | ||
.PARAMETER JitFile | ||
[Array] The path of the JIT trace profiles to include in the site extension. | ||
.PARAMETER Force | ||
[Switch] Include to overwrite existing files. | ||
.INPUTS | ||
None. You can't pipe objects to Compress-SiteExtension.ps1. | ||
.OUTPUTS | ||
None. Compress-SiteExtension.ps1 doesn't generate any output. | ||
#> | ||
|
||
param ( | ||
[string] $InputPath = $null, | ||
[string] $OutputPath = $null, | ||
[string[]] $JitFile = @(), | ||
[switch] $Force | ||
) | ||
|
||
if (-not $InputPath) | ||
{ | ||
$InputPath = (Get-ChildItem -Path . -Filter "extension.xml" -Recurse).Directory.FullName | ||
} | ||
|
||
if (Test-Path (Join-Path $InputPath "WebJobs.Script.SiteExtension.csproj")) | ||
{ | ||
Write-Error "This script should not be ran in the WebJobs.Script.SiteExtension project folder. Run this script in the root of the published site extension folder." | ||
exit 1 | ||
} | ||
|
||
if (-not (Join-Path $InputPath "extension.xml" | Test-Path)) | ||
{ | ||
Write-Error "Unable to find published site extension." | ||
exit 1 | ||
} | ||
|
||
if (-not $OutputPath) | ||
{ | ||
$OutputPath = (Split-Path $InputPath -Leaf) + ".zip" | ||
} | ||
|
||
if (Test-Path $OutputPath) | ||
{ | ||
if ($Force) | ||
{ | ||
Remove-Item -Path $OutputPath -Recurse -Force | ||
} | ||
else | ||
{ | ||
Write-Error "OutputPath already exists. Use -Force to overwrite." | ||
exit 1 | ||
} | ||
} | ||
|
||
if ($JitFile) | ||
{ | ||
$destinations = Get-ChildItem -Path $InputPath -Filter .jitmarker -Recurse | ||
$JitFile | ForEach-Object { | ||
$file = $_ | ||
$destinations | ForEach-Object { | ||
Write-Host "Copying JIT trace file $file to $($_.Directory)" | ||
Copy-Item -Path $file -Destination $_.Directory -Force | ||
} | ||
} | ||
} | ||
|
||
try | ||
{ | ||
Compress-Archive -Path "$InputPath/*" -DestinationPath $OutputPath | ||
Write-Host "Published site extension to $OutputPath" | ||
} | ||
finally | ||
{ | ||
# Cleanup JitTrace files | ||
if ($JitFile) | ||
{ | ||
$JitFile | ForEach-Object { | ||
$file = Split-Path $_ -Leaf | ||
$destinations | ForEach-Object { | ||
Remove-Item -Path (Join-Path $_.Directory $file) | ||
} | ||
} | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This file is used to mark the location for .jittrace file insertion |
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