azure-pipelines-task-lib: "The environment block used to start a process cannot be longer than 65535 bytes" on Windows Server 2012

Hi guys,

I have encountered a problem recently which I can`t get resolved anyhow.

I have a Release definition for one of my projects which consists of 16 artifacts. Additionally there are multiple variables configured per Environment in release definition. It was all working fine until one day random VSTS tasks started to fail with an error: The environment block used to start a process cannot be longer than 65535 bytes.

The proejct is alive so yes - we surely added new env variables and thus hit the limit reported by Task.

The question is why is there a limit at all? According to a doc I found here: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682653(v=vs.85).aspx There is no limit on the size of environment variables block in windows server >= 2008.

The log below comes from Azure SQL : DacpacTask VSTS Task run from an agent built on Windows Server 2012 but the problem also happens in different Tasks, i.e. Azure Powershell.

As far as I understand the exception is thrown by Add-Task in either LongPathFunctions.ps1 or VstsTaskSdk.psm1. Both from this project so my guess was to seek help here 😃

Can you please verify if this is an expected behaviour? Help much appreciated 😃

2017-03-27T08:46:43.7681116Z ##[section]Starting: Execute Azure SQL : DacpacTask 2017-03-27T08:46:43.7681116Z ============================================================================== 2017-03-27T08:46:43.7681116Z Task : Azure SQL Database Deployment 2017-03-27T08:46:43.7681116Z Description : Deploy Azure SQL DB using DACPAC or run scripts using SQLCMD 2017-03-27T08:46:43.7681116Z Version : 1.1.8 2017-03-27T08:46:43.7681116Z Author : Microsoft Corporation 2017-03-27T08:46:43.7681116Z Help : More Information 2017-03-27T08:46:43.7681116Z ============================================================================== 2017-03-27T08:46:44.5497039Z Add-Type : The environment block used to start a process cannot be longer than 65535 bytes. Your environment block is 2017-03-27T08:46:44.5497039Z 67054 bytes long. Remove some environment variables and try again. 2017-03-27T08:46:44.5497039Z At F:\vsts-build-03-01_work_tasks\SqlAzureDacpacDeployment_ce85a08b-a538-4d2b-8589-1d37a9ab970f\1.1.8\ps_modules\Vsts 2017-03-27T08:46:44.5497039Z TaskSdk\LongPathFunctions.ps1:212 char:1 2017-03-27T08:46:44.5497039Z + Add-Type -Debug:$false -TypeDefinition @’ 2017-03-27T08:46:44.5497039Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2017-03-27T08:46:44.5497039Z + CategoryInfo : NotSpecified: (😃 [Add-Type], InvalidOperationException 2017-03-27T08:46:44.5497039Z + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.AddTypeCommand 2017-03-27T08:46:44.5497039Z
2017-03-27T08:46:44.6273561Z Add-Type : The environment block used to start a process cannot be longer than 65535 bytes. Your environment block is 2017-03-27T08:46:44.6273561Z 67054 bytes long. Remove some environment variables and try again. 2017-03-27T08:46:44.6273561Z At F:\vsts-build-03-01_work_tasks\SqlAzureDacpacDeployment_ce85a08b-a538-4d2b-8589-1d37a9ab970f\1.1.8\ps_modules\Vsts 2017-03-27T08:46:44.6273561Z TaskSdk\VstsTaskSdk.psm1:74 char:1 2017-03-27T08:46:44.6273561Z + Add-Type -WarningAction SilentlyContinue -Debug:$false -TypeDefinition @’ 2017-03-27T08:46:44.6273561Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2017-03-27T08:46:44.6273561Z + CategoryInfo : NotSpecified: (😃 [Add-Type], InvalidOperationException 2017-03-27T08:46:44.6273561Z + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.AddTypeCommand 2017-03-27T08:46:44.6273561Z
2017-03-27T08:46:46.4083331Z ##[error]Unable to find type [VstsTaskSdk.TerminationException]. Make sure that the assembly that contains this type is loaded. 2017-03-27T08:46:46.5333150Z ##[error]Exit code 1 returned from process: file name ‘C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe’, arguments ‘-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". ([scriptblock]::Create(‘if (!$PSHOME) { $null = Get-Item -LiteralPath ‘‘variable:PSHOME’’ } else { Import-Module -Name ([System.IO.Path]::Combine($PSHOME, ‘‘Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1’’)) ; Import-Module -Name ([System.IO.Path]::Combine($PSHOME, ‘‘Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1’’)) }’)) 2>&1 | ForEach-Object { Write-Verbose $_.Exception.Message -Verbose } ; Import-Module -Name ‘F:\vsts-build-03-01_work_tasks\SqlAzureDacpacDeployment_ce85a08b-a538-4d2b-8589-1d37a9ab970f\1.1.8\ps_modules\VstsTaskSdk\VstsTaskSdk.psd1’ -ArgumentList @{ NonInteractive = $true } -ErrorAction Stop ; $VerbosePreference = ‘SilentlyContinue’ ; $DebugPreference = ‘SilentlyContinue’ ; Invoke-VstsTaskScript -ScriptBlock ([scriptblock]::Create(’. ‘‘F:\vsts-build-03-01_work_tasks\SqlAzureDacpacDeployment_ce85a08b-a538-4d2b-8589-1d37a9ab970f\1.1.8\DeploySqlAzure.ps1’’‘))"’. 2017-03-27T08:46:46.5333150Z ##[section]Finishing: Execute Azure SQL : DacpacTask

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 28 (17 by maintainers)

Most upvoted comments