1

I'm trying in my XAML template to put as argument the name of the current build, so I put as String argument: "BuildDetail.BuildNumber" But after queue my build I have this error:

`Exception Message: Could not find a part of the path 'C:\Windows\system32\BuildDetail.BuildNumber'. (type DirectoryNotFoundExceptio`n)

Thank you very much!

EDIT, where I want to put the argument:

enter image description here

And the build number format ($(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)): enter image description here

EDIT 2, I follow this: TFS 2010 : Use the label name in build number format enter image description here

And I found that:

 Exception Message: The root element of the build process template found at $/test8/BuildProcessTemplatest8/BuildProcessSourcet8/Templates/CustomTemplatet8.xaml (version C239) is not valid. (The build process failed validation. Details: 
Validation Error: The private implementation of activity '1: DynamicActivity' has the following validation error:   Compiler error(s) encountered processing expression "String.Format("$(BuildDefinitionName)_$(Date:yyyyMMdd)_{0}$(Rev:.r)", BuildDetail.SourceGetVersion)".
'Microsoft.TeamFoundation.Build.Client.BuildDetail' is not accessible in this context because it is 'Friend'.
Community
  • 1
  • 1
FrankVDB
  • 235
  • 2
  • 4
  • 16

1 Answers1

0

You could use build variables. For XAML build, it's TF_BUILD environment variables, more details please refer this thread.

TF_BUILD_BUILDNUMBER The build number of the build. For example: CIBuild_20130613.6.


Update

Use environment data from a custom build process

If you need to use an environment variable in your custom build process template, you can use the GetEnvironmentVariable activity to get the data. You can get data from any of the WellKnownEnvironmentVariables.

For example, to get the path to the binaries directory, set the Name property of the GetEnvironmentVariable activity to Microsoft.TeamFoundation.Build.Activities.Extensions.WellKnownEnvironmentVariables.BinariesDirectory

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • Humm I tried with this but it doesn't work, I edit my first message. The build number format is this one for me: $(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r) – FrankVDB Apr 04 '17 at 06:50
  • @FrankVDB Looks like you could directly use **BuildDirectory** argument , takes a look at this similar question: http://stackoverflow.com/questions/16267283/copy-files-from-tfs-to-build-drop-location-using-copy-directory-activity There is no use with builddetail.buildnumber in sourcelocation. – PatrickLu-MSFT Apr 04 '17 at 07:26
  • Besides, if you want to use a customize path, you could use something like this `Path.Combine(SourcesDirectory, "MyFileFolder")`, more details have a look at Dave's answer in this: http://stackoverflow.com/questions/24563341/creating-a-build-process-template-which-does-nothing-but-copy-all-files-to-anoth – PatrickLu-MSFT Apr 04 '17 at 07:37
  • I found this unfortunately, it seems to be wrong to get that during the build process: "String.Format("{0}\Sources", BuildDirectory)". 'BuildDirectory' is not declared. It may be inaccessible due to its protection level. – FrankVDB Apr 04 '17 at 08:36
  • @FrankVDB Yes, agree with you. Moreover, since you are using TFS2017. XAML Build are deprecated in TFS 2017 and will not be available in tge next version of TFS. VSTS already no longer supports them. https://www.visualstudio.com/en-us/docs/build/concepts/agents/hosted#im-looking-for-the-hosted-xaml-build-controller-where-did-it-go Highly recommend you to convert your builds to vNext Build to access some new technology and support. [Why Should I Leave XAML Builds?](http://blog.devmatter.com/why-should-i-leave-xaml-builds/) – PatrickLu-MSFT Apr 04 '17 at 08:45
  • Sorry, Ididn't use XAML build for a long time. Actually it's **SourceDirectory** something like $(Build.SourcesDirectory) or SourceDirectory in TFS2015 https://stackoverflow.com/questions/20139688/what-is-build-agent-folder-sourcedir-of-a-build-definition-in-tfs-build-201 – PatrickLu-MSFT Apr 04 '17 at 08:52
  • It doesn't work yet, I edit my first message, Thank you for taking your time! – FrankVDB Apr 04 '17 at 09:52
  • @FrankVDB Hi, Frank please go through my update answer. To use an environment variable in your custom build process template, you need to use the `GetEnvironmentVariable` activity to get the data. – PatrickLu-MSFT Apr 06 '17 at 01:48