I'm trying to run a Powershell script during my build process, but I can't figure out how to access the ps1 file which is checked into source control (TFS 2010). There is a similar SO question that exists, but I'm actually not sure if it's correct:
TFS 2010: run powershell script stored in source control
My TFS source control is setup as such:
=Project
==BuildScripts
===MyScript.ps1
==Code
===Dir1
====MySolution.sln
I thought passing something like SourcesDirectory + "\..\..\MyScript.ps1"
(to tell Powershell where the script is) would work, but I think I'm off somewhere.
Can someone help me figure out how to reference the ps1 file, and run it?
You will need to have a Workspace setup in your Build Definition that includes the directory with the Powershell script.
So your mapping might be like:
*Server* *Workspace*
$/Project/Code/Dir - $(SourcesDir)
You will need to add:
*Server* *Workspace*
$/Project/Code/Dir - $(SourcesDir)
$/Project/BuildScripts - $(SourcesDir)/BuildScripts
Your InvokeProcess can then pass Path.Combine(SourceDirectory, "BuildScripts", "MyScript.ps1")
to the Powershell command line.
N.B. You could also set the $/Project/Code/Dir
workspace to $(SourcesDir)/Code
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With