如何使用 TFS 服务器获取 .proj (MSBuild) 中的 BuildNumber
我们将 TFS 2010 与 VS 2010 一起用于 PHP Web 项目。实际上我们没有任何 .proj 或 .sln 文件,所以我自己制作了构建,它看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<ItemGroup>
<ZipFiles Include="**\*.*"/>
</ItemGroup>
<Target Name="Zip" >
<Zip Files="@(ZipFiles)" ZipFileName="$(OutDir)myzip.zip" />
</Target>
<Target Name="Build" DependsOnTargets="Zip">
<Message Text="My Build Complete - $(BuildNumber) - $(TeamProject) - $(BuildProperties)" />
</Target>
<Target Name="AfterBuild">
<MakeDir Directories="Testing" />
<Message Text="My AfterBuild- $(BuildNumber) "></Message>
</Target>
</Project>
我在 VS 的构建定义中将构建号配置为“$(BuildDefinitionName)_$(Date:yyyyMMdd )$(Rev:.r)" ,并正确创建网络路径上的放置文件夹。
问题是 $(BuildNumber) 或 $(TeamProject) 或 $(BuildProperties) 为空。而且“My Afterbuild”似乎从未执行过。
为什么我的变量为空以及如何从指定的构建定义中获取构建号?
We use TFS 2010 with VS 2010 for PHP web projects. Actually we do not have any .proj or .sln file, so i have made my own to make builds, it looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<ItemGroup>
<ZipFiles Include="**\*.*"/>
</ItemGroup>
<Target Name="Zip" >
<Zip Files="@(ZipFiles)" ZipFileName="$(OutDir)myzip.zip" />
</Target>
<Target Name="Build" DependsOnTargets="Zip">
<Message Text="My Build Complete - $(BuildNumber) - $(TeamProject) - $(BuildProperties)" />
</Target>
<Target Name="AfterBuild">
<MakeDir Directories="Testing" />
<Message Text="My AfterBuild- $(BuildNumber) "></Message>
</Target>
</Project>
I have configured build numbers in build definition in VS as "$(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)" , and drop folder on network path is created correctly.
The problem is that $(BuildNumber) or $(TeamProject) or $(BuildProperties) are empty. Also it seems that "My Afterbuild" is never executed.
Why are my variables empty and how to get build number from build definition as specified?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
运行
AfterBuild
目标:对我来说,不清楚为什么
Zip
目标应该在Build
目标之前执行?编辑:
您必须通过手动将 BuildNumber 添加到 MSBuild 命令行来更新模板文件
defaultTemplate.XAML
,因此命令行将如下所示:请参阅有关此技巧的原始文章:< a href="http://blogs.msdn.com/b/jpricket/archive/2011/01/26/tfs2010-where-is-buildnumber.aspx" rel="nofollow">TFS2010 – $(BuildNumber) 在哪里?
To run
AfterBuild
targets:For me is not clear why
Zip
target should be executed before theBuild
target?EDIT:
You have to update template file
defaultTemplate.XAML
by adding manually BuildNumber to the MSBuild command line so command Line would be like:See the original article regarding this trick: TFS2010 – Where is $(BuildNumber)?