This sample allows the user to specify a set of terms to search for by specifying a set of XML files containing the term definitions. The user-configurable settings are stored in the project file. The scan can be invoked either on command or as an integrated part of the build process. When the scan is performed, a custom task provider causes hits, if any, to be shown in the task list.




This sample:

* Demonstrates writing MSBuild tasks, which run as part of the build.
* Demonstrates communicating information from an MSBuild task back to the host IDE using .NET remoting.
* Shows how to store and retrieve information in both MSBuild projects and non-MSBuild projects.
* Shows how to implement a custom task provider, including a custom toolbar and shortcut menu.
* Demonstrates how to place commands on the Project menu and the Solution Explorer shortcut menu, and how to handle them.
* Includes an algorithm to search for multiple terms across multiple streams of characters.

This sample is divided into several projects:
1. Scanner: class library that implements the scanning functionality.
2. BuildTask: MSBuild task implementation that allows the scan to run as part of the build process.
3. VsPackage: Visual Studio Package (VSPackage) implementation that provides a UI for the scanning functionality.
4. Utilities: generally useful utility functions used by other projects in the solution.

The terms to search for are defined in XML files. For an example of the supported format, see
VsPackage\sampletermtable.xml. A term may have zero or more "exclusions", which define
contexts in which it will not count as a hit. The list of term tables to use is specified on
a per-project basis, and can be configured in the dialog box invoked by the CodeSweep command (on
the Project menu or Solution Explorer shortcut menu).

Only files with supported extensions can be scanned; others are ignored. This restriction
exists so that large binary files can be avoided if desired. The default list of supported
extensions is found in extensions.xml, which is copied to the user's Application Data\Microsoft\CodeSweep
folder on first run. To support new extensions, add them to that file.

A scan can be invoked either by MSBuild during the build process, or explicitly
by the user at any time. In either case - to invoke explicitly or to control invocation during builds - use the configuration dialog box. If the scan is enabled to run during
the build, it will be run in command-line builds as well as builds in the IDE.

When a scan is performed, the results are sent to the Task List. To see them, click CodeSweep in the
provider drop-down list on the Task List toolbar. In the list of results, you can double-click a result to go to its location. The CodeSweep Task List toolbar contains four buttons: Stop Scan,
Repeat Last Scan, Ignore, and Show Ignored Instances. The Ignore command marks the selected
result(s) as ignored, which means that they will not be shown in the Task List (even in
future scans). To see the ignored instances, click the Show Ignored Instances button. The
shortcut menu also contains these commands.



Download and install


Building and running the sample