<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Versioning &#8211; BeatificaBytes</title>
	<atom:link href="https://www.BeatificaBytes.be/tag/versioning/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.BeatificaBytes.be</link>
	<description>The Joys of Computing</description>
	<lastBuildDate>Sun, 04 Nov 2012 14:44:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8</generator>
	<item>
		<title>Assembly Version, File Version and Product Version: The Butterfly Effect</title>
		<link>https://www.BeatificaBytes.be/assembly-version-file-version-and-product-version-the-butterfly-effect/</link>
					<comments>https://www.BeatificaBytes.be/assembly-version-file-version-and-product-version-the-butterfly-effect/#respond</comments>
		
		<dc:creator><![CDATA[vletroye]]></dc:creator>
		<pubDate>Sun, 04 Nov 2012 14:44:48 +0000</pubDate>
				<category><![CDATA[TFS]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Team Build]]></category>
		<category><![CDATA[Versioning]]></category>
		<guid isPermaLink="false">/wordpress/?p=603</guid>

					<description><![CDATA[Assembly Version, File Version and Product Version are &#8220;related&#8221; if you don&#8217;t specify them explicitly&#8230; and you could be surprised by one of the side [&#8230;]]]></description>
										<content:encoded><![CDATA[<p style="text-align: justify;">Assembly Version, File Version and Product Version are &#8220;related&#8221; if you don&#8217;t specify them explicitly&#8230; and you could be surprised by one of the side effect: loosing you application data or user settings when incrementing the Assembly File Version.</p>
<p style="text-align: justify;"><span class="collapseomatic " id="id69b5228b6e8b0"  tabindex="0" title="Click to Read More"    >Click to Read More</span><span id='swap-id69b5228b6e8b0'  class='colomat-swap' style='display:none;'>Click to Close</span><div id="target-id69b5228b6e8b0" class="collapseomatic_content ">
<p style="text-align: justify;"><span style="text-decoration: underline;"><strong>How are those versions specified:</strong></span></p>
<p style="text-align: justify;">By default, any new Visual Studio Project includes an AssemblyInfo file defining default values (major, minor, build and revision) for the Assembly Version and Assembly File Version:</p>
<pre>[csharp][assembly: AssemblyVersion(&quot;1.0.0.0&quot;)]
[assembly: AssemblyFileVersion(&quot;1.0.0.0&quot;)][/csharp]</pre>
<ul style="text-align: justify;">
<li>A difference in the <strong>build</strong> number represents a recompilation of the same source. This is usually appropriate because of processor, platform, or compiler changes.</li>
<li>Assemblies with the same name, major, and minor version numbers but different <strong>revision</strong> numbers are intended to be fully interchangeable. This is usually appropriate for security fix, etc &#8230;</li>
<li>“[assembly: AssemblyVersion(&#8220;<strong>65534.65534.65534.65534</strong>&#8220;)]” is maximum.</li>
</ul>
<p style="padding-left: 30px; text-align: justify;">MSBuild can auto-increment the build and revision numbers at each build if we provide a (*) in place of those figures. Ex.</p>
<pre>[csharp][assembly: AssemblyVersion(&quot;1.0.*&quot;)][/csharp]</pre>
<p><span style="text-align: justify;">or<br />
</span></p>
<pre>[csharp][assembly: AssemblyVersion(&quot;1.0.0.*&quot;)][/csharp]</pre>
<p style="padding-left: 60px; text-align: justify;">In such cases, the build number is generated based on the current day and the revision number is generated based on the number of seconds since midnight. Replacing the revision number only with a (*) would be irrelevant. Indeed, consecutive builds would most probably have lower revisions.</p>
<p style="text-align: justify;">There is no default value set for the Product Version when creating a new Visual Studio Project. But a value can be set manually in the AssemblyInfo file using:</p>
<pre>[csharp][assembly: AssemblyInformationalVersion(&quot;1.0.0.0&quot;)][/csharp]</pre>
<p style="padding-left: 60px; text-align: justify;">Usually, the Product Version is a value like major.minor.build, but it can actually be any string, like &#8220;1.0 RC&#8221;, etc&#8230; Don&#8217;t use (*) in this string as it wouldn&#8217;t be replaced by an auto-incremented figure. Instead, it would crash your application in some cases (See further for the explanation). Notice also that before VS 2010, using anything else that major.minor.build.rev was resulting in  false warning during compilation.</p>
<p style="text-align: justify;"><span style="text-decoration: underline;"><strong>What do those versions mean:</strong></span></p>
<p style="padding-left: 30px; text-align: justify;"><em><strong>Assembly Version</strong> : This is the version number used by framework during build and at runtime to locate, link and load the assemblies. When you add reference to any assembly in your project, it is this version number which gets embedded. At runtime, CLR looks for assembly with this version number to load. But remember this version is used along with name, public key token and culture information only if the assemblies are strong-named signed. If assemblies are not strong-named signed, only file names are used for loading.</em><br />
<em> </em><br />
<em><strong>Assembly File Version</strong> : This is the version number given to file as in file system. It is displayed by Windows Explorer. Its never used by .NET framework or runtime for referencing. But it can be used by OS tools.</em></p>
<p style="padding-left: 30px; text-align: justify;"><strong>Product Version</strong> <em>(a.k.a Assembly Informational Version): Defines an additional version information for an assembly manifest. This is the version you would use when talking to customers or for display on your website.</em>.</p>
<p style="text-align: justify;"><span style="text-decoration: underline;"><strong>What if a version is not specified:</strong></span></p>
<ul style="text-align: justify;">
<li>If the Assembly version is not explicitly specified, it takes the value of 0.0.0.0.</li>
<li>If the Assembly File version is not explicitly specified, it takes the value of the Assembly version.</li>
<li>If the Product version is not explicitly specified, it takes the value of the Assembly File version.</li>
</ul>
<div style="text-align: justify;"><span style="text-decoration: underline;"><strong>How could issues occurred due to this relation:</strong></span></div>
<p style="text-align: justify;">By your fault <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p style="text-align: justify;">At work, we recently decided to manage the major and minor numbers of the Assembly Versions at build time, within our TFS Build Process Template. Assembly Versions&#8217; build and release numbers are kept equal to 0 while major and minor are enforced with values provided through Build Definitions&#8217; parameters. At the same time,  we auto-increment the build and release numbers of the Assembly File Versions while keeping their major and minor numbers aligned with those of the Assembly Versions. We don&#8217;t touch the Product Version. This was designed as recommended in <a title="Assembly Version Management" href="http://support.microsoft.com/kb/556041/en-us" target="_blank" rel="noopener noreferrer">KB 556041</a>.</p>
<p style="padding-left: 30px; text-align: justify;">As mentioned, major and minor numbers are specified through custom parameters of our Build Definitions. The build number is computed to reflect directly the current day using a format like &#8220;YMMdd&#8221; with Y = year modulo x to be &lt;= 6 (None of our product has a longer life). The release number is set with the auto-incremented value provided out-of-the box by Team Build.</p>
<p style="text-align: justify;">Previously, most of the binaries were compiled locally, on development workstations, and there was no version management at all (There was simply no need for any such versioning): Assembly Version and Assembly File Version were always kept unchanged.</p>
<p style="text-align: justify;">The change introduced with our Build Process Template had an unexpected consequence: As there never was any Product Version specified explicitly in the AssemblyInfo, binaries&#8217; Product Versions were always equal to the Assembly File Version&#8230; kept therefore unchanged through all builds. However, since we started to auto-increment the Assembly File Version, the Product Version started to increment too&#8230;</p>
<p style="text-align: justify;">And ? And some users started to complain that their custom settings were lost after the installation of each new version&#8230;</p>
<p style="text-align: justify;">We quickly noticed that, as usually recommended, developers were making use the two following properties to store  respectively application&#8217;s data and users&#8217; data:</p>
<pre>[csharp]Application.CommonAppDataPath[/csharp]</pre>
<pre>[csharp]Application.LocalUserAppDataPath[/csharp]</pre>
<p style="text-align: justify;">And after <a title="Persisting Application Settings" href="http://msdn.microsoft.com/en-us/library/ms973902.aspx" target="_blank" rel="noopener noreferrer">some investigations on MSDN</a>, it appeared that the path returned by those properties depend among other on the Product Version <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f641.png" alt="🙁" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p style="text-align: justify;">Depending on the OS, CommonAppDataPath is usually like:</p>
<ul>
<li>%SystemDrive%\Documents and Settings\All Users\Application Data\&lt;<em>CompanyName</em>&gt;\&lt;<em>ProductName&gt;</em>\<em>&lt;</em><strong>ProductVersion</strong><em>&gt;</em> or</li>
<li>%SystemDrive%\ProgramData\&lt;<em>CompanyName</em>&gt;\&lt;<em>ProductName&gt;</em>\<em>&lt;<strong>ProductVersion</strong>&gt;</em></li>
</ul>
<p style="text-align: justify;">And LocalUserAppDataPath is like:</p>
<ul>
<li>&#8220;%SystemDrive%\Documents and Settings\<em>&lt;UserId&gt;</em>\Local Settings\Application Data\&lt;<em>CompanyName</em>&gt;\&lt;<em>ProductName&gt;</em>\<em>&lt;<strong>ProductVersion</strong>&gt;</em>&#8221; or</li>
<li>&#8220;%SystemDrive%\Users\<em>&lt;UserId&gt;</em>\AppData\Local\&lt;<em>CompanyName</em>&gt;\&lt;<em>ProductName&gt;</em>\<em>&lt;<strong>ProductVersion</strong>&gt;</em>&#8220;.</li>
</ul>
<p style="text-align: justify;">So, indeed, each new release of our product having now a new Product Version, application&#8217;s data and users&#8217; data of the previous versions are not used anymore&#8230;</p>
<p style="text-align: justify; padding-left: 30px;">Any (*) used in the Product Version (e.g.: 1.0.*) wouldn&#8217;t be replaced by auto-incremented build/release numbers (as mentioned previously), the &#8220;AppDataPath&#8221;  above would contain an illegal character; reason why the application would crash when accessing this path.</p>
<p style="text-align: justify;">This also impacted applications accessing settings in the registry with methods like:</p>
<pre>[csharp]Application.UserAppDataRegistry.SetValue()[/csharp]</pre>
<pre>[csharp]Application.CommonAppDataRegistry.SetValue()[/csharp]</pre>
<p>Those methods access respectively data under <strong><br />
</strong></p>
<ul>
<li><strong>HKCU</strong>\Software\&lt;CompanyName&gt;\&lt;ProductName&gt;\&lt;<strong>ProductVersion</strong>&gt;\</li>
<li><strong>HKLM</strong>\Software\&lt;CompanyName&gt;\&lt;ProductName&gt;\&lt;<strong>ProductVersion</strong>&gt;\</li>
</ul>
<div><del>Read also this paper on <a title="User Settings Management" href="http://www.blayd.co.uk/article.aspx?pageid=1013" target="_blank" rel="noopener noreferrer">User Settings Management</a>.</del></div>
<div>See also one of <a title="Various Assembly Version" href="http://philippetruche.wordpress.com/tag/assemblyinformationalversion" target="_blank" rel="noopener noreferrer">my sources here</a> about this topic.</div>
<p style="text-align: justify;"></div>
<div class="pvc_clear"></div>
<p id="pvc_stats_603" class="pvc_stats total_only  " data-element-id="603" style=""><i class="pvc-stats-icon medium" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" version="1.0" viewBox="0 0 502 315" preserveAspectRatio="xMidYMid meet"><g transform="translate(0,332) scale(0.1,-0.1)" fill="" stroke="none"><path d="M2394 3279 l-29 -30 -3 -207 c-2 -182 0 -211 15 -242 39 -76 157 -76 196 0 15 31 17 60 15 243 l-3 209 -33 29 c-26 23 -41 29 -80 29 -41 0 -53 -5 -78 -31z"/><path d="M3085 3251 c-45 -19 -58 -50 -96 -229 -47 -217 -49 -260 -13 -295 52 -53 146 -42 177 20 16 31 87 366 87 410 0 70 -86 122 -155 94z"/><path d="M1751 3234 c-13 -9 -29 -31 -37 -50 -12 -29 -10 -49 21 -204 19 -94 39 -189 45 -210 14 -50 54 -80 110 -80 34 0 48 6 76 34 21 21 34 44 34 59 0 14 -18 113 -40 219 -37 178 -43 195 -70 221 -36 32 -101 37 -139 11z"/><path d="M1163 3073 c-36 -7 -73 -59 -73 -102 0 -56 133 -378 171 -413 34 -32 83 -37 129 -13 70 36 67 87 -16 290 -86 209 -89 214 -129 231 -35 14 -42 15 -82 7z"/><path d="M3689 3066 c-15 -9 -33 -30 -42 -48 -48 -103 -147 -355 -147 -375 0 -98 131 -148 192 -74 13 15 57 108 97 206 80 196 84 226 37 273 -30 30 -99 39 -137 18z"/><path d="M583 2784 c-38 -19 -67 -74 -58 -113 9 -42 211 -354 242 -373 16 -10 45 -18 66 -18 51 0 107 52 107 100 0 39 -1 41 -124 234 -80 126 -108 162 -133 173 -41 17 -61 16 -100 -3z"/><path d="M4250 2784 c-14 -9 -74 -91 -133 -183 -95 -150 -107 -173 -107 -213 0 -55 33 -94 87 -104 67 -13 90 8 211 198 130 202 137 225 78 284 -27 27 -42 34 -72 34 -22 0 -50 -8 -64 -16z"/><path d="M2275 2693 c-553 -48 -1095 -270 -1585 -649 -135 -104 -459 -423 -483 -476 -23 -49 -22 -139 2 -186 73 -142 361 -457 571 -626 285 -228 642 -407 990 -497 242 -63 336 -73 660 -74 310 0 370 5 595 52 535 111 1045 392 1455 803 122 121 250 273 275 326 19 41 19 137 0 174 -41 79 -309 363 -465 492 -447 370 -946 591 -1479 653 -113 14 -422 18 -536 8z m395 -428 c171 -34 330 -124 456 -258 112 -119 167 -219 211 -378 27 -96 24 -300 -5 -401 -72 -255 -236 -447 -474 -557 -132 -62 -201 -76 -368 -76 -167 0 -236 14 -368 76 -213 98 -373 271 -451 485 -162 444 86 934 547 1084 153 49 292 57 452 25z m909 -232 c222 -123 408 -262 593 -441 76 -74 138 -139 138 -144 0 -16 -233 -242 -330 -319 -155 -123 -309 -223 -461 -299 l-81 -41 32 46 c18 26 49 83 70 128 143 306 141 649 -6 957 -25 52 -61 116 -79 142 l-34 47 45 -20 c26 -10 76 -36 113 -56z m-2057 25 c-40 -58 -105 -190 -130 -263 -110 -324 -59 -707 132 -981 25 -35 42 -64 37 -64 -19 0 -241 119 -326 174 -188 122 -406 314 -532 468 l-58 71 108 103 c185 178 428 349 672 473 66 33 121 60 123 61 2 0 -10 -19 -26 -42z"/><path d="M2375 1950 c-198 -44 -350 -190 -395 -379 -18 -76 -8 -221 19 -290 114 -284 457 -406 731 -260 98 52 188 154 231 260 27 69 37 214 19 290 -38 163 -166 304 -326 360 -67 23 -215 33 -279 19z"/></g></svg></i> <img decoding="async" width="16" height="16" alt="Loading" src="https://www.BeatificaBytes.be/wp-content/plugins/page-views-count/ajax-loader-2x.gif" border=0 /></p>
<div class="pvc_clear"></div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.BeatificaBytes.be/assembly-version-file-version-and-product-version-the-butterfly-effect/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
