cleantestresults XML Snippet

About a year ago, I wrote about an automated way to clean up the TestResults folder created by VSTS. While I still use this approach methodically, I've begun to find it tedious to find my original post to copy and paste the XML into the project file. For this reason, I've created an XML code snippet that inserts the relevant elements:

 <?xml version="1.0" encoding="utf-8" ?>
 <CodeSnippets  xmlns="https://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
   <CodeSnippet Format="1.0.0">
     <Header>
       <Title>cleantestresults</Title>
       <Shortcut>cleantestresults</Shortcut>
       <Description>Code snippet for cleaning the TestResults folder. Only to be used from an MSBuild file.</Description>
       <Author>Mark Seemann</Author>
       <SnippetTypes>
         <SnippetType>Expansion</SnippetType>
       </SnippetTypes>
     </Header>
     <Snippet>
       <Declarations>
         <Literal Editable="false">
           <ID>Dollar</ID>
           <Default>$</Default>
             </Literal>
          </Declarations>
       <Code Language="XML">
         <![CDATA[<PropertyGroup>
   <TestResultsFolderPath>..\TestResults</TestResultsFolderPath>
 </PropertyGroup>
 <Target Name="AfterClean">
   <RemoveDir Directories="$Dollar$(TestResultsFolderPath)" Condition="Exists('$Dollar$(TestResultsFolderPath)')" />
 </Target>]]>
       </Code>
     </Snippet>
   </CodeSnippet>
 </CodeSnippets>

I've also included this snippet as an attachment to this post, so the easiest way to use this is to download it and put it into your <documents>\Visual Studio 2005\Code Snippets\XML\My Xml Snippets folder.

To insert this snippet when editing a project file in Visual Studio, just hit Ctrl+K, X (or click EditIntellisenseInsert Snippet).

cleantestresults.snippet