I have a powershell script that works wonderfully from the powershell shell and from a cmd window, and now I am trying to launch it from a post-build step in Visual Studio.
After several different variations of trying to get this to lunch and run successfully, I currently have the following configuration for the "Command Line" property of the "Post-Build Event" in VS2010.
This is all on one line in the Post-Build configuration, but I've wrapped the text here just for readability:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive
-File "$(SolutionDir)testScript.ps1"
-ConfigurationFile "$(SolutionDir)configuration.txt"
-SolutionDir "$(SolutionDir)"
-Platform "$(Platform)"
-Configuration "$(Configuration)"
The powershell script expects 4 mandatory parameters: ConfigurationFile, SolutionDir, Platform, and Configuration. As you can see, I am providing each of those parameters above, and am enclosing them in double quotes to protect against spaces in the values.
In VS2010, the SolutionDir macro expands to a path that has spaces, Platform expands to "Release", and Configuration expands to "Win32".
When the post-build step executes, this is the error I get:
testScript.ps1 : Cannot process command because of one or more missing
mandatory parameters: Platform Configuration.
+ CategoryInfo : InvalidArgument: (:) [testScript.ps1],
ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingMandatoryParameter,testScript.ps1
...any ideas what I could be missing? It is apparently able to find the script in $(SolutionDir), but I can't tell whether it's picking up any of the command line arguments. Could the trailing '\' character in $(SolutionDir) be hanging this up?