3

I have a large number of projects (300+) and I have Powershell module commands to build these. These PS modules are wrapping MsBuild.exe and working successfully at Command Prompt.

However, I am trying to find a way to fit these Build Commands into TFS so that I can schedule builds (Rolling builds) through TFS among team members.

So far, I am unable to start with some suitable option to use Powershell script/commands to call from TFS instead of Msbuild.

Only Solution Guessed: is that I might need to create some OurBuild.Proj file and use Msbuild tasks to specify our Powershell commands and then set OutBuild.proj file to build in my Build Definition.

But I'm not sure if Powershell scripts/commands can be called like that. Because those scripts would further call Msbuild.exe while setting the environment by calling "%VS100COMNTOOLS%"VsVars32.bat at start.

Can someone please give us a head-start or point to some good tutorial/guide?

7
  • You should seriously consider whether you can do without the PowerShell scripts and get things to work with just standard project files. Otherwise, you'll always be in the position of "trying to make the PowerShell scripts work" in the new environment. Your technique also loses you the ability to do simple builds that just reference .sln files. Commented Dec 3, 2013 at 19:36
  • @JohnSaunders. Purpose is to build the projects at command line as well as can be scheduled remotely on a build server. So I'm just trying to use single procedure (i.e. Powershell modules) in both scenarios. At command line, it is working like a charm. Commented Dec 4, 2013 at 5:45
  • MSBUILD is capable of command-line builds. You are sailing against the tide. Commented Dec 4, 2013 at 12:18
  • @JohnSaunders I have wrapped MSBuild with its command line args in Powershell module, so actually tide is in my jar. :) Commented Dec 5, 2013 at 7:09
  • And now you're talking about TFS builds, so you get to create build definitions to call MSBUILD with the necessary arguments - but not so much if it is wrapped by PowerShell, without creating custom build activities. Commented Dec 5, 2013 at 13:04

1 Answer 1

4

Since you're allowed to build your own Build process xaml file, you can make it look like anything you want. I find it easiest to open up the DefaultBuildProcessTemplate.xaml in sourcecontrol and then start there. The basics like fetching sources, setting and selecting the build agent can be kept as is, but the logic around building projects, and probably running the tests, you can take out and customize to your hearts content. Calling a powershell script is actually pretty simple (you might want to have a look at the 2013 templates on how you might be able to set that up.

From a reporting perspective you might want to do some additional work to make sure that your platform and configuration are correctly transferred from the build to the call to MsBuild (inside your powershell), and normally Team Build will also supply a set of additional loggers to ensure that warnings and errors correctly end up in the datawarehouse.

Giving you a thorough answer that covers everything is going to be a lot of work, so please start from here and ask additional questions when you get stuck.

Recommended reading:

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

1 Comment

thanks for such useful detailed reply. now that includes a learning curve. will definitely go for that..

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.