2

Using Windows Workflow in TFS2010, I set up a PS script to run at end of build process. Followed example in http://www.ewaldhofman.nl/post/2010/11/09/Part-14-Execute-a-PowerShell-script.aspx to a T and it appears correct in Process section of build definition. However, no matter what I set arg to the dir path of script, the result is always...

The term '.\DataServiceCpy.ps1' is not recognized as the name of a cmdlet, func tion, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I've tried 10 variations of the path. I enabled PS scripts to run on build server and I can run the script successfully from cmd prompt.

Anything obvious that I am overlooking?

many thanks...

5
  • is the ps script available in the outdir? Commented Feb 24, 2013 at 6:07
  • The ps script is added to source control one directory down from workflow .xaml file. It's as if it's not being recognized. Should I append the portion of workflow xaml to which this pertains? Commented Feb 24, 2013 at 17:22
  • Yes the activity and the input to the activity will help Commented Feb 25, 2013 at 4:04
  • It doesnt mean being under the template directory it will be available in build - especialy in root. You either need to find it relative to your workspace in source directory or you need to put it in custom assemlby folder configured for controller and get the path to that from build environment (this is stored in xaml workflow extension or you can pass it to activity using parameters). Also i suggest to get asbsolute path (with System.IO.Path) inside activity and call ps with that - this way you will see what exactly your calling - then you can just go to your buildserver and check. Commented Feb 25, 2013 at 7:17
  • Ok I've added a link to screenshots of the setup ...s1285.beta.photobucket.com/user/Rickie_Oths/media/… Commented Feb 25, 2013 at 18:19

2 Answers 2

4

In TFS 2013 (not sure for others) exists RunScript activity which is placed into "Team Foundation Build Activities" in Toolbox. I prefer that activity when I want to execute some custom script.

To use this you need to first create arguments (at least one for script path)! To create arguments follow this post.

After you created argument for script path you need to navigate yourself to "Metadata" argument on arguments tab. Add your created argument and also add following statement in "Editor" field: Microsoft.TeamFoundation.Build.Controls.ServerFileBrowserEditor, Microsoft.TeamFoundation.Build.Controls

After that go to "Properties" on RunScript activity and into FilePath insert following statement: AdvancedBuildSettings.GetValue(Of String)("PUT_HERE_YOUR_ARGUMENT_NAME", String.Empty)

Note that you need to insert in last statement exactly name of your argument which you created for script path.

After you are done:

  • check in your changes;
  • go to build definition "Process" tab and press "Refresh" button in "Build process template" section;

These steps will allows you to browse your source control and choose your script which you want without providing path.

If you don't need to insert new activity, you can just modify old arguments.

Sign up to request clarification or add additional context in comments.

3 Comments

When you create the argument, how should you specify the path to the script?
If you implemented like in above you should be able to go to "Process" tab in your build template and browse your script which exist on source control. In which part you are stuck?
The script just doesn't run, in the diagnostic there's only: Inputs EnvironmentVariables: Enabled: True Arguments: FilePath: Outputs Result: 0
1

I did it the same way using the same blog and it worked for me. The only difference that I see is that my Powershell script lives in the solution/project folder and in the build definition I specify the powershell script using a relative path. Having a relative path works well with ConvertWorkspaceItem activity. You may want to check (output) the file path that you get after your ConverntWorkspaceItem activity to see if that is the right path.

I hope that helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.