如何使用 TFS 服务器获取 .proj (MSBuild) 中的 BuildNumber

发布于 2024-12-03 05:17:08 字数 1196 浏览 0 评论 0原文

我们将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无语# 2024-12-10 05:17:08

运行 AfterBuild 目标:

<DefaultTargets="AfterBuild" />

<Target Name="Build" DependsOnTargets="Zip">

<Target Name="AfterBuild" DependsOnTargets="Build">

对我来说,不清楚为什么 Zip 目标应该在 Build 目标之前执行?

编辑:

您必须通过手动将 BuildNumber 添加到 MSBuild 命令行来更新模板文件 defaultTemplate.XAML,因此命令行将如下所示:

<mtbwa:MSBuild CommandLineArguments="[String.Format("
        /p:SkipInvalidConfigurations=true 
        /p:BuildNumber={1} {0}", 
        MSBuildArguments, 
        BuildDetail.BuildNumber)]" />

请参阅有关此技巧的原始文章:< 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:

<DefaultTargets="AfterBuild" />

<Target Name="Build" DependsOnTargets="Zip">

<Target Name="AfterBuild" DependsOnTargets="Build">

For me is not clear why Zip target should be executed before the Build 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:

<mtbwa:MSBuild CommandLineArguments="[String.Format("
        /p:SkipInvalidConfigurations=true 
        /p:BuildNumber={1} {0}", 
        MSBuildArguments, 
        BuildDetail.BuildNumber)]" />

See the original article regarding this trick: TFS2010 – Where is $(BuildNumber)?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文