Customize a Build Template to Exclude Symbols From Being Published to the Symbol Server

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.

Pre-Requisites

Customization Steps

My template is based on the default TFS template TfvcTemplate.12.xaml and customized with the following changes:

  1. Start off by adding the build template parameter that accepts filter:

    • ExclusionFilter - Text that would be used as part of the wild card filter.

      Build Process Parameter

  2. Next, the variables that would be needed:

    • CustomAllSymbolsList - Temporarily store the symbol files that are found
    • CustomExcludedSymbolsList - 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.

      Build Process Variables

  3. Now get the WellKnowEnvironmentalVariables.BinariesDirectory value using the GetEnvironmentalVariable<T> activity.

    GetEnvironmentalVariable<T>

    Built-In Environmental Variable

  4. Get a list of all the available symbols from the build folder.

    • This is done using a FindMatchingFiles activity with a String.Format("{0}\**\*.pdb", CustomBinDirectory) pattern.

    Find All Symbols

  5. Get a list of of symbols that need to be excluded from the Symbol Server.

    • Again, a FindMatchingFiles activity with String.Format("{0}\**\*{1}*.pdb", CustomBinDirectory, ExclusionFilter) pattern.

    Find Symbols to be excluded

  6. Since the FindMatchingFiles activity returns an IEnumberable<string> we create a new list that we can actually manipulate.

    Find Symbols to be excluded

  7. Add all the symbols to the new list.

    Add symbols

  8. Remove the symbols that need to be excluded.

    Remove symbols

  9. Pass the filtered collection into the PublishSymbols activity via the FileList property.

    PublishSymbols Activity

    PublishSymbols, FileList

Using the Build Definition

Create a new build definition using the new template and provide valid values for Path to publish symbolsand ExclusionFilter parameters.

Edit build definition

Finally, queue a new build and verify that the symbols are excluded the symbols store.

The final customized template can be downloaded here.

References

comments powered by Disqus