我有一个PowerShell脚本,可以在PowerShell窗口和cmd窗口中完美运行,现在我正在尝试从Visual Studio的“后期构建步骤”中启动它。
在多次尝试不同的变化来成功地启动和运行它之后,我目前在VS2010的“后期构建事件”的“命令行”属性中具有以下配置。
这全部都在“后期构建配置”中的一行上,但我在这里换行以便阅读。
在多次尝试不同的变化来成功地启动和运行它之后,我目前在VS2010的“后期构建事件”的“命令行”属性中具有以下配置。
这全部都在“后期构建配置”中的一行上,但我在这里换行以便阅读。
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive
-File "$(SolutionDir)testScript.ps1"
-ConfigurationFile "$(SolutionDir)configuration.txt"
-SolutionDir "$(SolutionDir)"
-Platform "$(Platform)"
-Configuration "$(Configuration)"
这个powershell脚本提供了4个必填参数:ConfigurationFile,SolutionDir,Platform和Configuration。如上所示,我已经提供了每个参数,并将它们用双引号括起来,以防止值中有空格。
在VS2010中,SolutionDir宏会扩展为带有空格的路径,Platform会扩展为“ Release”,而Configuration会扩展为“ Win32”。
当后置生成步骤执行时,我得到了以下错误:
testScript.ps1 : Cannot process command because of one or more missing
mandatory parameters: Platform Configuration.
+ CategoryInfo : InvalidArgument: (:) [testScript.ps1],
ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingMandatoryParameter,testScript.ps1
你有什么想法是我可能漏掉了什么吗?它显然能在$(SolutionDir)中找到脚本,但我无法确定它是否获取了任何命令行参数。 $(SolutionDir)中的末尾'\'字符是否有问题?