|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
It works,thanks a lot!
|
#2
|
|||
|
|||
I have one more issue,if param MyParam2 contains { I got an error at step Run Test PowerShell script-with parameters :
3/8/2023 12:26:39 AM: Building project step 2 - Run Test PowerShell script-with parameters... C:\Windows\System32\WindowsPowerShell\v1.0\powersh ell.exe -nologo -noninteractive -executionpolicy Unrestricted "& 'C:\Program Files\VisBuildPro9\Test.ps1' Test1 Test{2[]??" Missing closing '}' in statement block or type definition. + CategoryInfo : ParserError: ( : ) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingEndCurlyBrace This is because the powershell script is launched with parameters without enclosing ' ' For example if I launch the script from a batch file step by adding enclosing ' ' all is ok: 3/8/2023 12:30:42 AM: Building project step 3 - Run PowerShell script from batch step... C:\Windows\System32\WindowsPowerShell\v1.0\powersh ell.exe -nologo -noninteractive -executionpolicy Unrestricted "& 'C:\Program Files\VisBuildPro9\Test.ps1' -Param1 'Test1' -Param2 'Test{2[]??' Param1= Test1 Param2= Test{2[]?? Is there a way to add enclosing ' ' when using a Powershell step? I attached the bld project. |
#3
|
|||
|
|||
Add the single quotes to the parameter value.
|
#4
|
|||
|
|||
Tried that,same error:
C:\Windows\System32\WindowsPowerShell\v1.0\powersh ell.exe -nologo -noninteractive -executionpolicy Unrestricted "& 'C:\Program Files\VisBuildPro9\Test.ps1' Test1 ''Test{2[]??''" Missing closing '}' in statement block or type definition. + CategoryInfo : ParserError: ( [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingEndCurlyBrace I see now the second param has 2 chars ' at beginning and 2 at end although I added just one. |
#5
|
|||
|
|||
When I run your project in v10.8, I get a command like
... -File D:\Temp\Test.ps1 Test1 'Test{2[]??' |
#6
|
|||
|
|||
I am using VBP 9.7 but I think it does not make any difference.
Did you try to copy the Test.ps1 attached in a message above to the VBP folder(%PROJDIR%)? I get the error when running first step"Run Test PowerShell script-with parameters" which is running %PROJDIR%\Test.ps1 with 2 Input params : %MyParam1% '[vbld_EscapeString(vbld_AllMacros()("MyParam2"))]' The step "Run PowerShell script from batch step" is running ok as I put there the command with Param2 enclosed with' : C:\Windows\System32\WindowsPowerShell\v1.0\powersh ell.exe -nologo -noninteractive -executionpolicy Unrestricted "& '%PROJDIR%\Test.ps1' -Param1 '%MyParam1%' -Param2 '[vbld_EscapeString(vbld_AllMacros()("MyParam2"))]' |
#7
|
|||
|
|||
3/9/2023 6:53:24 PM: Building project step 2 - Run Test PowerShell script-with parameters...
C:\Program Files\PowerShell\7\pwsh.exe -nologo -noninteractive -executionpolicy Unrestricted -File D:\Temp\Test.ps1 Test1 'Test{2[]??' Param1= Test1 Param2= 'Test{2[]??' 3/9/2023 6:53:25 PM: Build successfully completed (elapsed = 00:00:00). |
Tags |
powershell , special charcaters |
|
|