Can I change source code with a Pre-build event?
I've got a variable, BuildDateTimeStamp, would it be possible to add a pre build event to update the value of this variable?
Code:
Dim BuildDateTimeStamp = #4/12/2011 10:29:19 AM#
Then if I rebuilt in a couple minutes, it would automatically change to
Code:
Dim BuildDateTimeStamp = #4/12/2011 10:35:23AM#
I have seen examples of people getting the build date from the version, but on this assembly the version is a static value that does not often change.
Re: Can I change source code with a Pre-build event?
I guess my questions are: what are you using this variable for? Does it need to be declared as a variable in your code? Or do you just need access to it's value? Can you use the modified date of the compiled file? (.exe, .dll - whatever you are compiling to)
Re: Can I change source code with a Pre-build event?
Quote:
I guess my questions are: what are you using this variable for?
I will be using it in the application for logging functionality.
Quote:
Does it need to be declared as a variable in your code? Or do you just need access to it's value?
I suppose I could use just the value.
Quote:
Can you use the modified date of the compiled file? (.exe, .dll - whatever you are compiling to)
This assembly is in the GAC, so I would rather not go down that road.
Here's a little more background information, this assembly is an add-in that is used by one of our vendor's products. If the version changes, the assembly needs to be reconfigured with the vendor's product, which is a pain, so we hard code the version. This makes it difficult to know which build is in which environment, which is why I would like to automatically set a build date, and log the value.
Re: Can I change source code with a Pre-build event?
Does this help? It looks like you can run pretty much whatever you want pre- and post-build.