<p>Every time I publish the application in <a href="http://en.wikipedia.org/wiki/ClickOnce" rel="nofollow noreferrer">ClickOnce</a> I get get it to update the revision number by one. Is there a way to get this change automatically to change the version number in AssemblyInfo.cs file (all our error reporting looks at the Assembly Version)?</p>

[{'answer_id': 44606, 'author': 'Judah Gabriel Himango', 'author_id': 536, 'author_profile': 'https://Stackoverflow.com/users/536', 'pm_score': 0, 'selected': False, 'text': '<p>You\'ll probably need to create a piece of code that updates AssemblyInfo.cs according to the version number stored in the .csproj file. (The ClickOnce deploy version is stored inside an XML tag.)</p>\n\n<p>You\'d then change your .csproj file to run this bit of code when Publish|Release build is performed. The MSBuild folks have blogged about how to perform custom actions during certain build types; check the <a href="http://blogs.msdn.com/msbuild/" rel="nofollow noreferrer">MSBuild team blog</a>.</p>\n'}, {'answer_id': 152430, 'author': 'Rinat Abdullin', 'author_id': 47366, 'author_profile': 'https://Stackoverflow.com/users/47366', 'pm_score': 2, 'selected': False, 'text': '<p>Steps:</p>\n\n<ol>\n<li>Use external incrementing version number (if you leverage a continuous integration server like CruiseControl.NET, then it comes from the build label).</li>\n<li>Use GlobalVersionInfo.cs (file link-referenced by all projects in your solution) to hold the current version and update it on the build with the AssemblyInfo task from the <a href="http://msbuildtasks.tigris.org/" rel="nofollow noreferrer">MSBuild Community</a> tasks.</li>\n<li>Script <a href="http://msdn.microsoft.com/en-us/library/acz3y3te%28v=vs.80%29.aspx" rel="nofollow noreferrer">Mage</a> command-line tool from the .NET SDK to update the ClickOnce manifest, using the same version (see the <code>-v</code> and <code>-mv</code> switches).</li>\n</ol>\n\n<p>BTW, a nice bonus is that, whenever you automatically publish a newer ClickOnce deployment version via the integration script, if you also specify the minimal version to mage.exe (same as version), then every user will be updated automatically on the next application launch.</p>\n'}, {'answer_id': 152493, 'author': 'Jason Stangroome', 'author_id': 20819, 'author_profile': 'https://Stackoverflow.com/users/20819', 'pm_score': 6, 'selected': True, 'text': '<p>We use Team Foundation Server Team Build and have added a block to the TFSBuild.proj\'s <code>AfterCompile</code> target to trigger the ClickOnce publish with our preferred version number:</p>\n\n<pre class="lang-xml prettyprint-override"><code>&lt;MSBuild Projects="$(SolutionRoot)\\MyProject\\Myproject.csproj"\n         Properties="PublishDir=$(OutDir)\\myProjectPublish\\;\n                     ApplicationVersion=$(PublishApplicationVersion);\n                     Configuration=$(Configuration);Platform=$(Platform)"\n         Targets="Publish" /&gt;\n</code></pre>\n\n<p>The <code>PublishApplicationVersion</code> variable is generated by a custom MSBuild task to use the TFS Changeset number, but you could use <a href="http://msdn.microsoft.com/en-us/library/t9883dzc.aspx" rel="nofollow noreferrer">your own custom task</a> or an <a href="http://msbuildtasks.tigris.org/" rel="nofollow noreferrer">existing solution</a> to get the version number from the AssemblyInfo file.</p>\n\n<p>This could theoretically be done in your project file (which is just an MSBuild script anyway), but I\'d recommend against deploying from a developer machine.</p>\n\n<p>I\'m sure other <a href="http://en.wikipedia.org/wiki/Continuous_integration" rel="nofollow noreferrer">continuous integration</a> (CI) solutions can handle this similarly.</p>\n\n<hr>\n\n<p><strong>Edit:</strong> Sorry, got your question backwards. Going from the ClickOnce version number to the AssemblyInfo file should be doable. I\'m sure the MSBuild Community Tasks (link above) have a task for updating the AssemblyInfo file, so you\'d just need a custom task to pull the version number from the ClickOnce configuration XML.</p>\n\n<p>However, you may also consider changing your error reporting to include the ClickOnce publish version too:</p>\n\n<pre class="lang-cs prettyprint-override"><code>if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)\n{\n    Debug.WriteLine(System.Deployment.Application.ApplicationDeployment.\n                                                        CurrentDeployment.CurrentVersion);\n}\n</code></pre>\n'}, {'answer_id': 376061, 'author': 'Todd', 'author_id': 14030, 'author_profile': 'https://Stackoverflow.com/users/14030', 'pm_score': 2, 'selected': False, 'text': '<p>I implemented this recently using some custom tasks. An issue I found with implementing this with ClickOnce is that all your DLL files are updated. This causes the ClickOnce update to download all the application files every update. This bypasses on of the nice features of the ClickOnce deployment where only the modified files are re-downloaded in an update.   </p>\n\n<p>Just something to think about when implementing something like this with ClickOnce.</p>\n'}]
['https://Stackoverflow.com/questions/44470', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3798/']