Friday, October 29, 2010

Executing a PowerShell script from TFS 2010 workflow

  1. Add an InvokeProcess activity to the workflow.
  2. Set the DisplayName property to something useful for logging and debugging.
  3. Set the FileName property to "powershell.exe"
  4. Set the Arguments like this:
    "-file """ + SourcesDirectory + "\Scripts\SetAssemblyVersions.ps1"" " + MajorVersionNumber.ToString() + " " + MinorVersionNumber.ToString() + " " + BuildDetail.SourceGetVersion.Substring(1) + " " + BuildDetail.BuildNumber.Substring(BuildDetail.BuildNumber.LastIndexOf(".") + 1)
  5. Give names to the standard output and error output streams.
  6. Add a WriteBuildMessage activity under the Handle Standard Output field and set its Message property to the standard output stream defined above.
  7. Add a WriteBuildError activity under the Handle Error Output field and set its Message property to the error output stream defined above.

0 comments:

Post a Comment