By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,463 Members | 2,954 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,463 IT Pros & Developers. It's quick & easy.

VB:Form - How to write version attribute out to database on post-build?

P: 1
Hi, I have a windows form application. I'd like to write the current version attribute out to a logfile automatically when the build completes. I've been looking at the post-build events and these seem to be only for command lines. I tried writing an executable console app that was called post-build to get the attribute version. My code looked like this:

Expand|Select|Wrap|Line Numbers
  1. Imports System
  2. Imports System.Text
  3. Imports System.IO
  4. Imports System.Reflection
  5.  
  6. Module AIRVerWriter
  7.  
  8.     Sub Main()
  9.         Dim asmAIR As Assembly
  10.         Dim avaAIR As AssemblyVersionAttribute
  11.  
  12.         asmAIR = Assembly.GetCallingAssembly()
  13.         avaAIR = AssemblyVersionAttribute.GetCustomAttribute(asmAIR, GetType(AssemblyVersionAttribute))
  14.  
  15.         Using sw As StreamWriter = New StreamWriter("c:\verlog.txt")
  16.  
  17.             sw.WriteLine(avaAIR.Tostring())
  18.             sw.Close()
  19.         End Using
  20.     End Sub
  21.  
  22. End Module
  23.  
I compiled and set this up as a post-build event, and it runs just fine, and writes to the desired log, but instead of writing my just-built project's version (1.3.3.4) it writes it's own version (1.0.0.0) to the log. How can I capture this information when I perform a build? I have tried a number of variations and they all give me the executing module's version, not the built module.

Windows XP SP2
VB.Net 2005
Thanks in advance,

Spellwvr
Jan 4 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.