Team Foundation Server: How to trigger or run a user script? - tfs

I am new to Microsoft TFS, (I am used to Perforce - a similar tool).
How can we trigger or run a user script automatically when ever a particular event occurs
in TFS?
For instance, I want to run my java file when ever a change to any file has been saved through TFS.
(In perforce I used "Change-commit triggers" to achieve this)
Please help me out.
EDIT: After some research,
I figured that we need to "Use the InvokeProcess activity to start a process (run a program) on the build server" from the following source.
But How do I use it?? I am using a "Microsoft Team Explorer for Visual Studio 2012". Not able to figure out how to use InvokeProcess.. Please help me out..

you can't use the default template for invoke process. you need a custom template to set up invoke process.
http://msdn.microsoft.com/en-us/library/ff805001(v=vs.100).aspx ( check the invokeprocess part in this link )

Did you try with Build option available in Team explorer?

Related

Clickonce app publishing using visual studio online

I am trying to clickonce-publish a client app compiled using the scriptable build system available on Visual Studio Online. It seems something new.
I was able to find some articles showing how to customize msbuild and add parameters to make it work on local TFS:
http://publicvoidlife.blogspot.pt/2014/05/continuous-integration-with-tfs-and.html?showComment=1441022327672 and
http://www.dontpaniclabs.com/blog/post/2011/04/29/clickonce-publish-and-deploy-from-team-foundation-server-2010/
But in Visual Studio Online there are some different things. I see there are some "build steps" I can set that include package/deploy scripts. Can I use them for clickonce?
If setting clickonce publish during msbuild is the way to go, how to set parameters on the "visual studio build" script?
I don't know how to specify the "publish" option on msbuild script ui nor how to specify necessary parameters.
Any ideas?
Thank you,
Just as described in the blogs you posted, you need to customize build process template to be able to publish clickonce app. Here is another link which is useful for you, from which you can check the detailed information on how to do the customization step by step (includes information on how to add arguments, how to add /t:publish msbuild arguments) (it is written for TFS2010, applies to VSO as well): http://www.codeproject.com/Articles/122388/TFS-Team-Build-with-ClickOnce-Applications

Creating build definition with visual studio

I am creating a build definition in visual studio 2013. As you know, while creating build definition we can also set the assembly (in "Automated Tests" section) which contains the unit test methods to run. I am able to create the definition till this point. Now, what I want is once the test run is over, I want to call an exe that will parse the Trx file generated as a result of test run and send the run results in an email.
Can anyone have an idea about where I can set the path to the exe and pass some arguments to it while creating build definition? If this cannot be done while creating definition, what else is the other way to achieve it?
Thanks!
What you ask involves multiple steps, especially if you want to pull the tool from version control (which is IMHO the best option).
See the ALM Rangers' Team Foundation Build Customization Guide for help and guidance on this topic.
Or you can just setup an email notification when the TFS Build completes. That should include the test run results, and a clickable link to go to the full build report.

TFS source control without Visual Studio?

Is it possible to use TFS source control without Visual Studio? I have to put some files in some source control, those files are stored in a folder in some server, that is something developed in Oracle forms. I just need to add those files in some source control and I'd like to use TFS for that. Any tips or tools could we use for this?
TFS is likely to be overkill for a few files in a single folder, but if the TFS infrastructure is already in place then it will work.
You will need Team Explorer (or, on non-Windows) Team Explorer Everywhere installed to give you the client tools. But you can perform all source code operations with the tf.exe command line (or equivalent from Team Explorer Everywhere).
Team Foundation Server Power Tools has Windows Shell Extensions that provides integration
with Windows Explorer and the common file dialogs. With this integration, you can perform many source control operations without having to run Visual Studio or a Team Foundation command-line tool.
see this answer but you will need to make sure you have tfs server running as well to connect to. Would it not be simpler to use git/mercurial/svn...{any other free source control system}?
I am one of the lovers of TFS, but I think in your case if you don't need to use Team Explorer or Team Explorer Everywhere (which will need command line used) for none windows I suggest to use SVN sub version (VisualSVN Server) it's open source and it has integrated OS shell (TortoiseSVN ) right click menu which will be easy than using command line
Vlad: That is true, but this important: I have used the "Shell Extensions" for a while only to realize that it does create problems. First of all, the "Shell Extensions" does not report errors during a check-in; it only unexpectedly stops, and the window closes.
Also, the reason I am looking for an external "Source Control Explorer" is that if you delete any file from Window Explorer that was under Source Control by TFS, the Check-In procedure will fail saying that there is a file missing. The correct way to safely delete a file is to do it through "Source Control Explorer"; the check-in then works. Usually not a problem, unless, like me, you have a Java project and have no integration between NetBeans & TFS.

TFS Custom Check-in Policy Debugging

I have created a custom check-in policy as given in the link below:
http://msdn.microsoft.com/en-us/library/bb668980.aspx
I followed the steps as explained by the article. Everything works fine. My doubt is - Is it possible for me to debug the code while check-in the code?
Consider I want to know what are the methods are called inside the CheckForCommentsPolicy class as stated in article or I have added some business logic which needs to debugged. Which process do I have to attach? or Do I have to follow any other approach for debugging?
Is it possible to debug? Kindly help me out.
Thanks in advance
While MrHinsh's method will in fact work I found that there is an even easier way to debug and would like to recommend that.
If you go to the properties of your checkin policy class project and look under the debug tab you will find a section for Start Action. Select to "Start external program" and browse to where you have visual studio installed.
for instance
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
With this in place and the proper registry keys for loading the policy DLL from your debug folder all you need to do is hit Run and a second copy of VS 2010 will load up and you can debug your class without doing the Debug | Attach to process steps.
Yes. You need to have two copies of Visual Studio open. One had your solution open and the other for running the code.
You need to select "Debug | Attach to Process..."
Figure: Open the Attach to process dialog
You can then see all the available process on your computer and you should see the other instace of Visual Studio (this is the one you will use to run your checkin policy).
Figure: Attach to the devenv.exe process
This will allow you to debug the instance of your Check-in Policy running in the copy of Visual Studio you just Attached to.
I got the answer:
http://msdn.microsoft.com/en-us/magazine/cc163320.aspx#S3

In TFS, once I have the build definition setup, how to I modify the task list etc?

I setup my build definition, is that all I do when it comes to setting up my build using the Team Explorer GUI?
It seems like the only thing for me to do now is edit the msbuild .proj file?
Is there a GUI for this or its all hand editing from here on it?
Currently there is no MSBuild editor inside Visual studio, but I've read that there gonna be one in Visual Studio Team System 2010 (one based on Workflow Foundation renderer).
If you really want a GUI you could try Microsoft Build Sidekick v2 but it is not free (55$) and not very useful in my opinion.
In TFS 2008 some of the information about a build can be edited through the GUI, but not much. If you right click on the build definition and choose Edit Build Definition you can change the workspace mappings, retention policy, drop location, and triggers. To change anything else you need to edit the .proj file.
What is it that you're trying to do? If you ask a specific question you might get interesting answers.

Resources