简体   繁体   English

从TFS MSBuild项目内部引用BuildNumber

[英]Referencing the BuildNumber from a inside a TFS MSBuild project

I'm trying to set-up a TFS build. 我正在尝试建立一个TFS构建。 I've customised the default TFS2013 workflow to obtain BuildDetail just before the MSBuild commmand. 我已自定义默认的TFS2013工作流程,以在MSBuild命令之前获取BuildDetail。 However, I now get a build error: 但是,我现在得到一个构建错误:

MSBUILD : error MSB1008: Only one project can be specified. MSBUILD:错误MSB1008:只能指定一个项目。 Switch: not 开关:不

For switch syntax, type "MSBuild /help" 对于开关语法,键入“ MSBuild / help”

My command line arguments are as follows: 我的命令行参数如下:

/target:publish;/p:PublishDir=\\Server1\PublishDir\;PublishingURL=https://www.website.com

I've played about with this, as I've read several questions on here along the same lines that point to a space, quote or a slash in the wrong place. 我已经玩过这个游戏了,因为我在这里读过几个相同的问题,它们指向空格,引号或错误位置的斜线。

I've also changed the MSBuild command to look like this: 我还更改了MSBuild命令,使其看起来像这样:

String.Format("/p:SkipInvalidConfigurations=true /p:BuildNumber={1} {0}", AdvancedBuildSettings.GetValue(Of String)("MSBuildArguments", String.Empty), BuildDetail.BuildNumber)

My target is to access the BuildNumber from within the proj file. 我的目标是从proj文件中访问BuildNumber。

Can anyone point me in the right direction to diagnose this? 谁能指出我正确的方向来诊断这一点?

EDIT: 编辑:

Based on the answer by @sburgess123 below, using $(TF_BUILD_BUILDNUMBER) causes an exception in the build. 根据下面@ sburgess123的回答,使用$(TF_BUILD_BUILDNUMBER)会导致生成异常。 The exception isn't massively helpful; 例外并没有太大帮助; but it's here: 但它在这里:

Run MSBuild 运行MSBuild

Exception Message: MSBuild error 1 has ended this build. 异常消息:MSBuild错误1已结束此生成。 You can find more specific information about the cause of this error in above messages. 您可以在上述消息中找到有关此错误原因的更多特定信息。 (type BuildProcessTerminateException) Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation) (类型BuildProcessTerminateException)异常堆栈跟踪:位于System.Activities.CodeActivity.InternalExecute(位于System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem处,位于System.Activities.CodeActivity.InternalExecute(ActivityInstance实例,ActivityExecutor执行程序,BookmarkManager书签管理器) .ExecuteBody(ActivityExecutor执行程序,BookmarkManager书签管理器,位置resultLocation)

Having looked, I can't find an actual error anywhere in the logs, but if I remove the reference to $(TF_BUILD_BUILDNUMBER) it's fine. 看完之后,我无法在日志中的任何地方找到实际的错误,但是如果删除对$(TF_BUILD_BUILDNUMBER)的引用,就可以了。

You don't need to modify the build process template to do this. 您无需修改​​构建过程模板即可执行此操作。 In 2013 there are a bunch of environment variables you have access to. 2013年,您可以访问许多环境变量。 See the section 'use environment variable data in msbuild' in the following link: 请参见以下链接中的“在msbuild中使用环境变量数据”部分:

http://msdn.microsoft.com/en-gb/library/hh850448.aspx http://msdn.microsoft.com/en-gb/library/hh850448.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM