I have a powershell script that works fine from the powershell shell and from the cmd window, and now I'm trying to start it from the post-build phase in Visual Studio.
After several different options for trying to achieve this for lunch and a successful launch, I currently have the following configuration for the Command Line property in the Post-Build Event in VS2010.
This is all on one line in the Post-Build setup, but I 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 power part of the script expects 4 required parameters: ConfigurationFile, SolutionDir, Platform and Configuration. As you can see, I provide each of these parameters above, and enclose them in double quotation marks to protect against spaces in the values.
In VS2010, the SolutionDir macro expands to a path with spaces, the platform expands to Release, and the Configuration expands to Win32.
When the step after the build is executed, 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 that I could lose? Apparently, it can find the script in $ (SolutionDir), but I canβt determine if it will accept any command line arguments. Could the trailing "\" character in $ (SolutionDir) suspend this?