How can I retrieve major/minor/build/revision number on build events

南笙酒味 提交于 2019-12-13 04:58:21

问题


Hy there!

I'm using this piece of code, to copy some files on post-build-event:

<PropertyGroup>
    <DemoPath1>..\demoPath1</DemoPath1>
</PropertyGroup>
<Target Name="AfterBuild">
    <Exec Command="robocopy $(ProjectDir)$(DemoPath1) $(ProjectDir)demoPath2/$(Revision) * /XD .svn _svn /XF *.cs /S" IgnoreExitCode="true" />
</Target>

As you can see, I would like to use $(Revision) - obviously, this is not going to work ...

Can anybody help me out?

@mods: I dunno exactly which tag to use ... on the one hand it's msbuild, on the other one visual studio ...? feel free to edit!


回答1:


The easiest way is:

<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
  <Output TaskParameter="Assemblies" ItemName="AssemblyVersion" />
</GetAssemblyIdentity>

and I've used it this way:

<Exec Command="robocopy $(ProjectDir)$(SomeProperty) $(ProjectDir)somePath/%(AssemblyVersion.Version) * /S" IgnoreExitCode="true" />



回答2:


You left out of your question where you want to get the version number from. However you get it, all you need to do is populate the $(Revision) property yourself. Give a little more detail and I can probably help you out.



来源:https://stackoverflow.com/questions/5139709/how-can-i-retrieve-major-minor-build-revision-number-on-build-events

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!