09 Feb 2015 | Team Foundation Server | Team Build
This post was inspired by a feedback provided by one of the commenters on this post. The requirement was to exclude certain third party symbols from being published to the symbol server. I thought I would take upon the challenge to implement this.
As suggested in the same comment thread, my approach would revolve around explicitly setting the FileList
property in the PublishSymbols
activity. I would set it to a list that includes only the symbols that I want published. And the symbols I want to be excluded would be handled through a wild card filter that is passed as a build template parameter.
My template is based on the default TFS template TfvcTemplate.12.xaml
and customized with the following changes:
Start off by adding the build template parameter that accepts filter:
ExclusionFilter
- Text that would be used as part of the wild card filter.
Next, the variables that would be needed:
CustomAllSymbolsList
- Temporarily store the symbol files that are foundCustomExcludedSymbolsList
- Temporarily store the symbols that need to be excluded.CustomFilteredSymbolsList
- The final list of symbols that would be published to the symbol server.CustomBinDirectory
- Temporary store the Binaries Directory path.
Now get the WellKnowEnvironmentalVariables.BinariesDirectory
value using the GetEnvironmentalVariable<T>
activity.
Get a list of all the available symbols from the build folder.
FindMatchingFiles
activity with a String.Format("{0}\**\*.pdb", CustomBinDirectory)
pattern.Get a list of of symbols that need to be excluded from the Symbol Server.
FindMatchingFiles
activity with String.Format("{0}\**\*{1}*.pdb", CustomBinDirectory, ExclusionFilter)
pattern.Since the FindMatchingFiles
activity returns an IEnumberable<string>
we create a new list that we can actually manipulate.
Add all the symbols to the new list.
Remove the symbols that need to be excluded.
Pass the filtered collection into the PublishSymbols
activity via the FileList
property.
Create a new build definition using the new template and provide valid values for Path to publish symbols
and ExclusionFilter
parameters.
Finally, queue a new build and verify that the symbols are excluded the symbols store.
The final customized template can be downloaded here.