Asterisks in WP7 Assembly Version Revision? WATCH OUT! They go missing!
Nov
3
Written by:
Thursday, November 03, 2011 10:24 PM
One cool feature in Visual Studio is to setup an Assembly Version with an asterisk, but if you use this, you’ll need to read on! It goes MIA if you’re not careful!
I recently released a WP7 app called DevTeach Ottawa 2011, and I found something very odd with updating the Version number, it went missing the SECOND time I updated it. HUH?! WTF? Wha????? Ya, it took me a bit of time to find THAT pattern!
CTOs Summary:
If you use an asterisk in your Assembly Version, Revision, don’t! They go MIA after you update it the next time. Setting the Build to an asterisk seems to be ok
Geeks Summary:
Background. In my Solution, Properties, Assembly Information, Assembly Version, I set it to 1.1.0.0, then I have code which dynamically loads THAT version number on the fly as my WP7 app is running. But what’s the point of dynamically reading if it’s not changing?
To make it change on the fly (aka dynamic), I put an asterisk in the revision textbox (textbox order is like this: major.minor.build.revision), and that tells the compile to substitute a random number for that revision value. COOL! Now it’s really dynamic (see below for proof that this works).
NOTE: You can either put an asterisk in the Assembly Version: Revision (last textbox) or the Build, no where else. If you TRY to put asterisk in both the Build and Revision textboxes, you’ll get an error (right).
In my case, I setup the Revision to be dynamic.

And this is how it looks at runtime.

Works like a charm! BEAUTIFUL! I now have a way to have the compiler generate me ever changing version numbers. When I goto release, I can just trust the version numbers will be dynamic, even with betas and patches. Weeeeeeeeell…………………..
Ok, so I’m tired, it’s time to goto bed. So I close down my computer (closing the project is the key here). Sometime later, I return back with new vigor and decide to implement a new feature! COOL! So! I really should up the minor version by one. COOL! But look and see what happensin the solution properties, Assembly Information dialog! Do you see the problem? HUH? Where’s my asterisk?!?!?!?!

If you DON’T change anything, you’ll notice it still works! You’ll continue to get the dynamic revision number you’ve grown accustomed to! If you poke around into the AssemblyInfo.cs file, you’ll see why things continue to work. It still has the asterisks in there.

BUT!!!!

As soon as you change one of those version values and hit the OK button you’ll LOSE your dynamic build version numbering.

Now, let’s go one step further! This problem is limited to JUST the Revision textbox value. If you change the Revision value to an asterisks, you’re all good. You can open, close VS all you want, THAT asterisks will persist across development sessions.

And at runtime, things look like this. Interestingly enough, although you didn’t put an asterisk in the Revision, you get that dynamically changing for free. Nice.

Now that I know WHY my version numbers were going MIA after I thought I was doing something good by implementing a new feature and trying to advertise it, it’s time to grab a coffee and get coding!
Resources
MSDN: Version Class
PCHenry.com: I just released my fourth WP7 app tonight! YAHOO! DevTeach Ottawa 2011
MSDN: AssemblyVersionAttribute Class (look for where it talks about asterisks in the Remarks and Notes)
Version numbers format (cause I always forget): Major.Minor.Build.Revision
stackoverflow: What are the differences between AssemblyVersion, AssemblyFileVersion and AssemblyInformationVersion?