I am using TortoiseHg + VisualHg on Visual Studio 2008. Has anyone found way to automatically create a tag (with the published version number) in Mercurial whenever I do a publish from VS?
Asked
Active
Viewed 404 times
2 Answers
3
You can run a custom script to perform the hg tag
operation as an "AfterPublish" action. Have a look at the MSBuild documentation:
You will need to modify your project to add a custom target like this:
<Project>
...
<Target Name="AfterBuild">
<Exec Command="hg tag %(TAGNAME)"/>
</Target>
</Project>

gavinb
- 19,278
- 3
- 45
- 60
-
Is there any way to automatically get the current publish version in the target command? – sventevit Aug 30 '11 at 12:01
-
1Yes, see this other SO [question](http://stackoverflow.com/questions/2990216/read-assembly-version-number-in-post-build-event). – Sumo Aug 31 '11 at 02:20
1
Thanks to gavinb's answer and Sumo's comment. This is the way I did it for my WinForms application:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterPublish">
<GetAssemblyIdentity AssemblyFiles="$(OutputPath)\$(AssemblyName).exe">
<Output TaskParameter="Assemblies" ItemName="AssemblyIdentities" />
</GetAssemblyIdentity>
<Exec Command="hg tag %(AssemblyIdentities.Version)" />
</Target>