tags:

views:

105

answers:

2

Hi,

I am using XNA 3.1 to develop a small game and I want to add the following two features:

1) Increment the build value every time I compile
2) Set the date/time of compilation

I want to be able to set the Date/Time of compile in the Window Title (like Crysis)
I found this but I need more details. I am using Visual Studio 2008.

Thanks,

+2  A: 

You can use this. It should do all that you want.

Adrian Faciu
This is also a useful thing to look into.
Dave
+3  A: 

You can set the assembly version to be automatically updated when you build by setting it's build number and revision number to * in your AssembyInfo.cs file:

[assembly: AssemblyVersion("1.0.*")]

Now the build number can be read from the assembly and you can use this to determine the date when your program was built. Check the documentation for the AssemblyVersionAttribute for more information.

Rune Grimstad
Yep, this is exactly what I ended up using. Here is the formula to convert it into DateTime: Datetime timeCompiled = new DateTime (build * TimeSpan.TicksPerDay + revision * TimeSpan.TicksPerSecond * 2).AddYears (1999); Note that Daylight savings time is ignored.
Dave
I did some checks and there may be a slight problem using the assembly version. You may see that the version is only updated the first time you compile after starting visual studio.
Rune Grimstad
No, everytime I do "rebuild" the time gets updated.
Dave
It does? Great! :-)
Rune Grimstad