Applying Source Analysis Policy on on sub folder of a TFS project

Sep 28, 2011 at 11:29 PM

First of all thanks for taking your time to implement this great policy!

I would like to setup Source Analysis Policy for on a TFS setup like followed:


$TFS_RootProject<"Main branch">\"SubItem_A"


However, I want/can only apply on one of the sub Items/Folder lets say folder "SubItem_C".
Is there any way by tweaking the source code for the policy to make this happen?


Sep 29, 2011 at 3:39 PM

The policy actually already supports that through the directory exclusion, you can just provide part of the path (the more specific the better) and any files which have that path in the name will not be processed. You can add exclusions to your policy settings through the Exclusions tab while you're editing the policy settings in TFS.

For example, if you create the exclusion with "Branch\SubItem_C" as the exclusion string any files which have that value in the path will be excluded. If you create the exclusion with "Branch\Sub" as the exclusion string all of the folders you listed would be excluded.

- Jeff

Sep 30, 2011 at 6:43 AM

Sorry for interfering, but it seemed to me that theoj asked about how to include "SubItem_C" only.
And what you answering is about how to exclude it by the filter.

Does it mean that there is no other way to enable policy just for "SubItem_C" except creating an "exclusion" for "SubItem_A", "SubItem_B" and "SubItem_D"?
(Bad thing there is that you probably will have to change its exclusion in future, when new subitems appear).

Or maybe I just got you wrong?


Best regards,
Oleg Shuruev

Sep 30, 2011 at 2:40 PM

Yeah I just misread what he was asking. At this point there is no policy "exclusion" that's been configured to allow only specific folders to be included in processing. It'd look pretty much the exact same as the current folder exclusion, with a ! operator on the part where it checks the path.

Sep 30, 2011 at 4:14 PM

Hi Jeff, Hi Oleg,

Thanks for your responses clarifying what I was missing. It would be great to have an include option in addition to the exclude one but being able to exclude already gives me what I need for the time being.

Thanks again for implementing this really useful policy.


Sep 30, 2011 at 7:06 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Oct 15, 2011 at 12:59 AM

HI Jeff,

thanks for the response. It would be awesome to have a include list additionally to the exclude list or instead.

Also it would be really great if an exclude (and include) list would reference the $\TFS\Path and not the local file path like for example: "c:\Path".

By switching it the TFS path it would not be required to have every engineer put the local files into the same local folder.

Would that be possible?

Oct 15, 2011 at 3:18 PM

Since the policy applies to a project, there is no need to put the project name in the path. Say if you had a folder structure that looked like:



If you setup the path that's used by the filter to where you mapped it to... say C:\MyProject\FolderA then yes, you would need everyone to map the project to the C:\MyProject folder. However, if you set the exclude to \FolderA the filter still works the same unless you have a folder structure like:




In the above example, it'd exclude both folders with FolderA in the path. I'm about 60% sure that when I started writing the project I had tried to use the TFS path, but it was causing a significant performance degredation (ex. communicating each time to the server to get the TFS path for the item that's being checked). That's why I had chosen the local path instead, if you're checking in 200+ files it would take significantly longer (1-2 seconds per item). So instead of it taking around 3 seconds to do all of the pieces of the checkin process it's now been bumped to 400 seconds (6 minutes).

If nothing else, ensuring the developers mapped the team project to a folder with the same name as the project you could use \MyProject\FolderA in the exclude path and it'd only catch the one path. Where they put it at on their box doesn't matter as long as the root folder is named the same.

Oct 16, 2011 at 8:39 PM

Hi Jeff,

thanks for the clarification. I will try it out but following our explanation this should be all I need.
Thanks for the detailed example!