Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Powershell script that lives in TFS source control

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?

like image 237
Matt Avatar asked Oct 08 '22 08:10

Matt


1 Answers

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.

like image 137
DaveShaw Avatar answered Oct 13 '22 12:10

DaveShaw