azure-pipelines-tasks: SqlDacpacDeploymentOnMachineGroupV0 - environment variable size failure

Related to: https://github.com/microsoft/azure-pipelines-extensions/issues/709 PR: https://github.com/microsoft/azure-pipelines-extensions/pull/710

SqlDacpacDeploymentOnMachineGroupV0 - 0.3.20 is using an older version of vstasksdk (0.8.2) resulting in System.InvalidOperationException: The environment block used to start a process cannot be longer than 65535 bytes. Your environment block is 69981 bytes long. Remove some environment variables and try again. when using a large number (50) of builds

If I replace ps_modules\VsTaskSdk(0.8.2) with the ps_modules\VsTaskSdk (0.11.0) from _tasks\Powershell(2.151.2)

and remove Add-Type from TaskModuleSqlUtility.psm1 (https://github.com/microsoft/azure-pipelines-extensions/blob/master/TaskModules/powershell/TaskModuleSqlUtility/TaskModuleSqlUtility.psm1)

the error goes way

Type: Bug

Enter Task Name: https://github.com/microsoft/azure-pipelines-tasks/tree/master/Tasks/SqlDacpacDeploymentOnMachineGroupV0

Environment

  • Server - Azure Pipelines

https://dev.azure.com/raulandborg/Enterprise releaseId=233

  • Agent - Private:

agent.version:2.158.0 agent.os:Windows_NT agent.osarchitecture:x64 agent.osversion:6.3.9600

Issue Description

[error]The environment block used to start a process cannot be longer than 65535 bytes. Your environment block is 69981 bytes long. Remove some environment variables and try again.

Task logs

2019-10-22T22:01:12.4806611Z ##[debug]Loading module from path 'C:\azagent\A1\_work\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d\0.3.20\ps_modules\TaskModuleSqlUtility\TaskModuleSqlUtility.psd1'.
2019-10-22T22:01:12.4924371Z ##[debug]Loading module from path 'C:\azagent\A1\_work\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d\0.3.20\ps_modules\TaskModuleSqlUtility\TaskModuleSqlUtility.psm1'.
2019-10-22T22:01:12.5302331Z ##[debug]NonInteractive: False
2019-10-22T22:01:12.6247888Z ##[debug]Exporting function 'Invoke-DacpacDeployment'.
2019-10-22T22:01:12.6297345Z ##[debug]Exporting function 'Invoke-SqlQueryDeployment'.
2019-10-22T22:01:12.6354879Z ##[debug]Adding exceptions types.
2019-10-22T22:01:12.8405840Z ##[debug]Caught exception from task script.
2019-10-22T22:01:12.8460442Z ##[debug]Error record:
2019-10-22T22:01:13.0209589Z ##[debug]Add-Type : The environment block used to start a process cannot be longer than 65535 bytes.  Your environment block is 69981 bytes long.  Remove some environment variables and try again.
2019-10-22T22:01:13.0253086Z ##[debug]At C:\azagent\A1\_work\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d\0.3.20\ps_modules\TaskModuleSqlUtility\TaskModuleSqlUtility.psm1:28 char:1
2019-10-22T22:01:13.0291491Z ##[debug]+ Add-Type -WarningAction SilentlyContinue -Debug:$false -TypeDefinitio ...
2019-10-22T22:01:13.0329949Z ##[debug]+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-10-22T22:01:13.0367923Z ##[debug]    + CategoryInfo          : NotSpecified: (:) [Add-Type], InvalidOperationEx    ception
2019-10-22T22:01:13.0412881Z ##[debug]    + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.Power    Shell.Commands.AddTypeCommand
2019-10-22T22:01:13.0451396Z ##[debug] 
2019-10-22T22:01:13.0518406Z ##[debug]Script stack trace:
2019-10-22T22:01:13.0633754Z ##[debug]at <ScriptBlock>, C:\azagent\A1\_work\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d\0.3.20\ps_modules\TaskModuleSqlUtility\TaskModuleSqlUtility.psm1: line 28
2019-10-22T22:01:13.0671795Z ##[debug]at <ScriptBlock>, C:\azagent\A1\_work\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d\0.3.20\Main.ps1: line 83
2019-10-22T22:01:13.0714939Z ##[debug]at <ScriptBlock>, <No file>: line 1
2019-10-22T22:01:13.0754792Z ##[debug]at <ScriptBlock>, <No file>: line 22
2019-10-22T22:01:13.0793196Z ##[debug]at <ScriptBlock>, <No file>: line 18
2019-10-22T22:01:13.0833300Z ##[debug]at <ScriptBlock>, <No file>: line 1
2019-10-22T22:01:13.0903951Z ##[debug]Exception:
2019-10-22T22:01:13.1035571Z ##[debug]System.InvalidOperationException: The environment block used to start a process cannot be longer than 65535 bytes.  Your environment block is 69981 bytes long.  Remove some environment variables and try again.
2019-10-22T22:01:13.1075452Z ##[debug]   at System.Diagnostics.EnvironmentBlock.ToByteArray(StringDictionary sd, Boolean unicode)
2019-10-22T22:01:13.1116420Z ##[debug]   at System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine)
2019-10-22T22:01:13.1158493Z ##[debug]   at System.CodeDom.Compiler.Executor.ExecWaitWithCapture(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine)
2019-10-22T22:01:13.1200267Z ##[debug]   at Microsoft.CSharp.CSharpCodeGenerator.Compile(CompilerParameters options, String compilerDirectory, String compilerExe, String arguments, String& outputFile, Int32& nativeReturnValue, String trueArgs)
2019-10-22T22:01:13.1240437Z ##[debug]   at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames)
2019-10-22T22:01:13.1278725Z ##[debug]   at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources)
2019-10-22T22:01:13.1321693Z ##[debug]   at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] sources)
2019-10-22T22:01:13.1364265Z ##[debug]   at Microsoft.PowerShell.Commands.AddTypeCommand.CompileAssemblyFromSource(List`1 generatedTypes)
2019-10-22T22:01:13.1405191Z ##[debug]   at Microsoft.PowerShell.Commands.AddTypeCommand.EndProcessing()
2019-10-22T22:01:13.1448472Z ##[debug]   at System.Management.Automation.CommandProcessorBase.Complete()

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (8 by maintainers)

Most upvoted comments

Great, closing it now ๐Ÿ˜ƒ

@20shivangi Yes, we are unblocked ๐Ÿ˜ƒ

@20shivangi Iโ€™ve created a request with the owner of the extension (Red Gate). They forwarded it to there developers.

I will keep you posted on progress (if it doesnโ€™t take too long to complete ๐Ÿ˜‰)

@amccool , did you share the logs ?