How can I change AssemblyProduct, AssemblyTitle using MSBuild?

Viewed 28321

I have an MSBuild script which compiles my existing solution but I'd like to change some properties of one of the projects within the solution at compile-time, including but not limited to AssemblyProduct and AssemblyTitle.

Here's a snippet of my build script:

  <Target Name="Compile" >
 <MSBuild Projects="..\MySolution.sln" 
             Properties="Configuration=MyReleaseConfig;Platform=x86" />
  </Target>

I've got one main executable and several DLLs that are compiled. I am aware of the MSBuild Extension Pack and I suspect it might help me to get to where I need to be, although I'm not sure how to proceed.

Can I selectively change AssemblyInfo properties at build time?

3 Answers
<Target Name="SetVersion">
<ItemGroup>
  <AssemblyInfoFiles  Include="$(TargetDir)\**\AssemblyInfo.cs"/>
</ItemGroup>

<Message Text="change the Version number for:"/>
<Message Text="%(AssemblyInfoFiles.FullPath)"/>

<MSbuild.ExtensionPack.Framework.AssemblyInfo 
 AssemblyInfoFiles="@(AssemblyInfoFiles)"
                                              AssemblyTitle="newTitle"
                                              AssemblyMajorVersion="2"
                                              AssemblyMinorVersion="0"/>

 </Target>
Related