How to Auto tag Mercurial on Visual Studio Publish?
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?
You can run a custom script to perform the hg tag
operation as an "AfterPublish" action. Have a look at the MSBuild documentation:
- How to: Extend the Visual Studio Build Process
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>
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>
精彩评论