views:

189

answers:

2

Hi,

I'm using Visual Studio 2010 and TFS 2010. Is there a way that dll version be automatically incremented with each TFS build?

Thanks

A: 

You can use Version task from msbuildtasks

Here's blog post by Jeremy Jameson with step-by-step instructions on how to use it.

bniwredyc
@bniwredyc: That blog post is about TFS 2008 and build tasks. But I'm searching for a TFS 2010 solution. TFS 2010 uses WF 4.0 instead of build tasks.
afsharm
@afsharm: just add MSBuild workflow activity to use task that you need.
bniwredyc
@bniwredyc: would you please explain how to do it?
afsharm
A: 

I have a blog post on how to version your assemblies in TFS Build 2010: How to Create a Custom Workflow Activity for TFS Build 2010 RTM

Jim Lamb
@Jim: I have spent a full day on reading your post and applying it on my project. I corrected all issues one by one. But finally it does not update `AssemblyVersion` in `AssemblyInfo.cs` without any error. In addition I didn't find anything in your sample code that indicates changes will be commit back on the source control. Also you blog post does not allow me to comment there.
afsharm
There's no need to commit the changes back to source control since the version is based on the build number. Modifying files in source control during a build is generally something you'll want to avoid. Are your assemblies getting versioned, or not?
Jim Lamb
@Jim: I now understand why no activity exists with source control. But assemblies are still not versioned. I traced the process by adding `WriteBuildWarning` just before calling `ReplaceInFile`, so I'm sure `ReplaceInFile` is executed. I just tried to use `UpdateVersionInfo` instead but still no assembly is versioned. I have put the activity in `Overal Build Process\ Run On Agent` just before `Initialize Variables` activity. May this be the root cause of `ReplaceInFile` and `UpdateVersionInfo` not to function?
afsharm
@Jim: Finally I got Activity Pack to work. Now it works greatly. Thanks.
afsharm