Add try/catch to CheckSdkSize script
This commit is contained in:
Родитель
09c0cf1a40
Коммит
48bf052b39
|
@ -10,25 +10,26 @@ $aiMinZip = Join-Path $releasePath -ChildPath "ai.min.zip";
|
|||
# zip ai.min.js file
|
||||
# Compress-Archive -Path $aiMin -DestinationPath $aiMinZip; #...I wish, but it doesn't work in VSTS ;(
|
||||
|
||||
if(-not (test-path($aiMinZip))) {
|
||||
set-content $aiMinZip ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
|
||||
(dir $aiMinZip).IsReadOnly = $false
|
||||
}
|
||||
$input = New-Object System.IO.FileStream $aiMin, ([IO.FileMode]::Open), ([IO.FileAccess]::Read), ([IO.FileShare]::Read)
|
||||
$buffer = New-Object byte[]($input.Length)
|
||||
$byteCount = $input.Read($buffer, 0, $input.Length)
|
||||
$input.Close();
|
||||
|
||||
$shellApplication = new-object -com shell.application
|
||||
$zipPackage = $shellApplication.NameSpace($aiMinZip)
|
||||
$zipPackage.CopyHere($aiMin)
|
||||
Start-sleep -milliseconds 500
|
||||
$output = New-Object System.IO.FileStream $aiMinZip, ([IO.FileMode]::Create), ([IO.FileAccess]::Write), ([IO.FileShare]::None)
|
||||
$gzipStream = New-Object System.IO.Compression.GzipStream $output, ([IO.Compression.CompressionMode]::Compress)
|
||||
|
||||
$gzipStream.Write($buffer, 0, $buffer.Length)
|
||||
$gzipStream.Close()
|
||||
|
||||
# Check sizes
|
||||
$aiSize = (Get-Item $ai).Length;
|
||||
$aiMinSize = (Get-Item $aiMin).Length;
|
||||
$aiMinZipSize = (Get-Item $aiMinZip).Length;
|
||||
|
||||
Write-Host "==== JS SDK size ==="
|
||||
Write-Host "ai.js: $aiSize bytes"
|
||||
Write-Host "ai.min.js: $aiMinSize bytes"
|
||||
Write-Host "ai.min.zip: $aiMinZipSize bytes"
|
||||
Write-Host ==== JS SDK size ===
|
||||
Write-Host ai.js: $aiSize bytes
|
||||
Write-Host ai.min.js: $aiMinSize bytes
|
||||
Write-Host ai.min.zip: $aiMinZipSize bytes
|
||||
|
||||
$currentDir = Get-Location;
|
||||
$aiDll = Join-Path $currentDir -ChildPath "Microsoft.ApplicationInsights.dll";
|
||||
|
@ -42,14 +43,22 @@ $metrics.Add('ai', $aiSize);
|
|||
$metrics.Add('ai.min', $aiMinSize);
|
||||
$metrics.Add('a.min.zip', $aiMinZipSize);
|
||||
|
||||
$telemetry.TrackEvent("JsSdkSize", $null, $metrics);
|
||||
$telemetry.Flush();
|
||||
Try
|
||||
{
|
||||
$telemetry.TrackEvent("JsSdkSize", $null, $metrics);
|
||||
$telemetry.Flush();
|
||||
}
|
||||
Catch
|
||||
{
|
||||
Write-Host Failed to send telemetry. Error: $_.Exception.Message;
|
||||
}
|
||||
|
||||
$MAX_SDK_SIZE = 25 * 1025; # size in bytes
|
||||
$MAX_SDK_SIZE = 25 * 1024; # size in bytes
|
||||
|
||||
If($aiMinZipSize -ge $MAX_SDK_SIZE) {
|
||||
Write-Host "JS SDK library is too big (minimized+zipped): $aiMinZipSize bytes, max allowed size: $MAX_SDK_SIZE bytes"
|
||||
Write-Host "Please contact kszostak@microsoft.com or the ChuckNorris team to increase the threashold."
|
||||
If($aiMinZipSize -ge $MAX_SDK_SIZE)
|
||||
{
|
||||
Write-Host JS SDK library is too big (minimized+zipped): $aiMinZipSize bytes, max allowed size: $MAX_SDK_SIZE bytes
|
||||
Write-Host Please contact kszostak@microsoft.com or the ChuckNorris team to increase the threashold.
|
||||
|
||||
throw "SDK too big";
|
||||
exit 1;
|
||||
|
|
Загрузка…
Ссылка в новой задаче