Click here to Skip to main content
13,300,625 members (52,778 online)
Click here to Skip to main content
Add your own
alternative version


12 bookmarked
Posted 28 Aug 2007


, 28 Aug 2007
Rate this:
Please Sign up or sign in to vote.
Add additional key/value pairs to the VERSIONINFO resource.

Screenshot - VersionInfo_ex_prop.png


Sometimes it's useful to add additional Key/Value pairs to the VERSIONINFO resource. The two most useful for me are, the time when the executable was built and on which machine it was built. The benefit of putting that information into the VERSIONINFO resource is that I can easily access it with Windows Explorer. This article describes how this can be accomplished by leveraging the integration of MSBUILD with VS2005.

Fortunately, VS2005 has the capability to take a .res file instead of an icon as input. The bad news here is that if a res file is used, it must be manually compiled (using rc.exe) and synchronization with the existing .NET assembly attributes (e.g., AssemblyTitleAttribute) is lost. This is where MSBUILD comes in. I wrote a small build script and a task that does the following:

  • Create a temporary .rc file
  • Scan 'AssemblyInfo.cs' and put data into .rc file
  • Add additional data to .rc file
  • Compile .rc into .res using rc.exe
  • Switch from icon option to resource file option
  • Delete temporary files after compilation

Using the Code

The first step that has to be done to get started with the code is to create a new folder in the MSBuild vendor extension path (usually, this is C:\Program Files\MSBuild) and manually copy the files CP.MSBuild.dll and CP.MSBuild.targets from the download there. The next step is to insert the following snippet to each C# project we want to have the additional processing.

<Import Project="$(MSBuildExtensionsPath)\<created folder>\CP.MSBuild.targets" />

Note that the build script will only work for C# projects that don't already use a resource file.

Points of Interest

The build script as published here is tailored to my current needs. The code and script, however, should be easy enough to read and modify that it can be used in more advanced scenarios.

The source download contains the two projects CP.MSBuild.csproj and TestApp.csproj. They should be all that is needed to debug the build script. Note, however, that CP.MSBuild has to be built before the TestApp can be built.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Reto Ravasio
Switzerland Switzerland
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171207.1 | Last Updated 28 Aug 2007
Article Copyright 2007 by Reto Ravasio
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid