solidify / vsts-task-tokenize-in-archive

VSTS build and release task to replace tokens in an archive file
5 stars 3 forks source link

Exception "Cannot bind argument to parameter 'Name' because it is an empty string." #9

Open rewarner1968 opened 4 years ago

rewarner1968 commented 4 years ago

In my file I have PubVersion and __CI_Date__ and I populate those variables with this PowerShell script that runs prior to Tokenization.

Get the Current Date and Time and Set Environment Variable

$CI_Date = date +"%a %m/%d/%y %I:%M %P UTC" Write-Output("##vso[task.setvariable variable=CI_Date;]" + $CI_Date)

Log the Captures Date and Time

Write-Verbose "The Release Date is $CI_Date" -verbose

Get the System Build Number Being Used for Release

$PubVersion = $env:BUILD_BUILDNUMBER Write-Output("##vso[task.setvariable variable=PubVersion;]" + $PubVersion)

Log the Build Number Being Used

Write-Verbose "The Build Version is $PubVersion" -verbose

In my other code bases everything works in this one it fails. Here is the error: 2019-11-04T15:56:01.8752887Z ##[section]Starting: Tokenize in _Layout.cshtml in .zip 2019-11-04T15:56:01.8869098Z ============================================================================== 2019-11-04T15:56:01.8869195Z Task : Tokenize in Archive 2019-11-04T15:56:01.8869246Z Description : Allows you to tokenize within an archive without unpacking. 2019-11-04T15:56:01.8869313Z Version : 1.1.2 2019-11-04T15:56:01.8869355Z Author : Solidify Labs 2019-11-04T15:56:01.8869425Z Help : More Information 2019-11-04T15:56:01.8869486Z ============================================================================== 2019-11-04T15:56:04.7727551Z Searching for all .zip files at D:\a\r1\a\ATS-Everalert-UI\drop\ATS.Web.zip 2019-11-04T15:56:04.7727908Z Searching for _Layout.cshtml inside .zip files 2019-11-04T15:56:04.8730425Z 2019-11-04T15:56:04.8738660Z GAC Version Location
2019-11-04T15:56:04.8740102Z --- ------- --------
2019-11-04T15:56:04.8783273Z True v4.0.30319 C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.IO.Compression.FileSystem\v4.0_4.0.0.0b77a... 2019-11-04T15:56:04.8828790Z Matched zip: D:\a\r1\a\ATS-Everalert-UI\drop\ATS.Web.zip 2019-11-04T15:56:05.0399331Z Matched file in zip: Content/D_C/a/1/s/ATS.Web/obj/Release/Package/PackageTmp/Views/Shared/_Layout.cshtml 2019-11-04T15:56:05.5710745Z ##[error]System.Management.Automation.MethodInvocationException: Exception calling "Replace" with "2" argument(s): "Cannot bind argument to parameter 'Name' because it is an empty string." ---> System.Management.Automation.ParameterBindingValidationException: Cannot bind argument to parameter 'Name' because it is an empty string. at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at System.Management.Automation.Interpreter.ActionCallInstruction2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary2 functionsToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args) at System.Management.Automation.ScriptBlock.<>cDisplayClass57_0.b0() at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action) at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List1 variablesToDefine, Dictionary2 functionsToDefine, Object[] args) at System.Management.Automation.ScriptBlock.InvokeAsDelegateHelper(Object dollarUnder, Object dollarThis, Object[] args) at lambda_method(Closure , Match ) at System.Text.RegularExpressions.RegexReplacement.Replace(MatchEvaluator evaluator, Regex regex, String input, Int32 count, Int32 startat) at System.Text.RegularExpressions.Regex.Replace(String input, MatchEvaluator evaluator) at CallSite.Target(Closure , CallSite , Object , Object , Object ) --- End of inner exception stack trace --- at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at System.Management.Automation.Interpreter.ActionCallInstruction2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary2 functionsToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args) at System.Management.Automation.ScriptBlock.<>c__DisplayClass57_0.b0() at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action) at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List1 variablesToDefine, Dictionary2 functionsToDefine, Object[] args) at System.Management.Automation.ScriptBlock.InvokeUsingCmdlet(Cmdlet contextCmdlet, Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Object[] args) at Microsoft.PowerShell.Commands.ForEachObjectCommand.ProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() 2019-11-04T15:56:05.6052690Z ##[section]Finishing: Tokenize in _Layout.cshtml in
.zip

Any assistance would be greatly appreciated.

acjimeneza commented 4 years ago

I had the same mistake, to solve it, I searched for undesired tokens inside the file that I wanted to replace the token-value (Web.config). In my case, I had a comment that used the token.