Built-In Rules

Assembly References

Definition

Verifies that assembly references are correct. This rule can be used to make sure all projects use consistent assembly references (e.g. to correct versions of common components).

<rule name="AssemblyReferenceRule" type="JelleDruyts.BuildCop.Rules.AssemblyReferences.AssemblyReferenceRule">
  <assemblyLocations>
    <assemblyLocation assemblyName="[...]"
                      assemblyPath="[...]" />
  </assemblyLocations>
</rule>

Example

The following example verifies that any assembly whose fully qualified name starts with "EnvDTE, Version=8.0.0.0" is referenced from a path that starts with "R:\References\VisualStudio\8.0" (in other words, that "EnvDTE.dll" is referenced from somewhere under "R:\References\VisualStudio\8.0"):

<rule name="AssemblyReferenceRule" type="JelleDruyts.BuildCop.Rules.AssemblyReferences.AssemblyReferenceRule">
  <assemblyLocations>
    <assemblyLocation assemblyName="EnvDTE, Version=8.0.0.0" assemblyPath="R:\References\VisualStudio\8.0" />
  </assemblyLocations>
</rule>

Build Properties

Definition

Verifies that build properties in a project file are correct. This rule can be used to generically check all MSBuild properties, including (but not limited to) the build properties that are defined inside the project's properties in Visual Studio.

<rule name="BuildPropertiesRule" type="JelleDruyts.BuildCop.Rules.BuildProperties.BuildPropertiesRule">
  <buildProperties>
    <buildProperty name="[...]"
                   value="[...]"
                   condition="[...]"
                   compareOption="[EqualTo|NotEqualTo|Exists|DoesNotExist|In|NotIn]"
                   stringCompareOption="[CurrentCulture|CurrentCultureIgnoreCase|InvariantCulture|InvariantCultureIgnoreCase|Ordinal|OrdinalIgnoreCase]" />
  </buildProperties>
</rule>

Example

The following example verifies that warnings are always treated as errors, that the output path is correctly set for both the Debug as the Release solution configuration (i.e. condition), and that the DocumentationFile property exists:

<rule name="Build Properties" type="JelleDruyts.BuildCop.Rules.BuildProperties.BuildPropertiesRule">
  <buildProperties>
    <buildProperty name="TreatWarningsAsErrors" value="true" />
    <buildProperty name="OutputPath" value="bin\Debug\" condition="Debug" stringCompareOption="OrdinalIgnoreCase" />
    <buildProperty name="OutputPath" value="bin\Release\" condition="Release" stringCompareOption="OrdinalIgnoreCase" />
    <buildProperty name="DocumentationFile" compareOption="Exists" />
  </buildProperties>
</rule>

Documentation File

Definition

Verifies that an XML documentation file is generated as part of the build, with the correct name (i.e. the name of the assembly with the .xml file extension).

This rule has no rule-specific configuration.

Example

The following example verifies that an XML documentation file is generated as part of the build.

<rule name="DocumentationFileRule" type="JelleDruyts.BuildCop.Rules.DocumentationFile.DocumentationFileRule" />

Naming Conventions

Definition

Verifies that certain naming conventions are respected.

<rule name="NamingConventionsRule" type="JelleDruyts.BuildCop.Rules.NamingConventions.NamingConventionsRule">
  <prefixes namespacePrefix="[...]"
            assemblyNamePrefix="[...]"
            assemblyNameShouldMatchRootNamespace="[true|false]" />
</rule>

Example

The following example verifies that the root namespace and assembly name start with "JelleDruyts" and are exactly the same.

<rule name="Naming Conventions" type="JelleDruyts.BuildCop.Rules.NamingConventions.NamingConventionsRule">
  <prefixes namespacePrefix="JelleDruyts"
            assemblyNamePrefix="JelleDruyts" 
            assemblyNameShouldMatchRootNamespace="true" />
</rule>

Orphaned Projects

Definition

Verifies that the MSBuild project files being analyzed are part of at least one Visual Studio solution (.sln) file.

<rule name="OrphanedProjects" type="JelleDruyts.BuildCop.Rules.OrphanedProjects.OrphanedProjectsRule">
  <solutions searchPath="[...]" />
</rule>

Example

The following example verifies that all MSBuild project files are part of solution files somewhere in the "D:\Projects\Source" path.

<rule name="OrphanedProjects" type="JelleDruyts.BuildCop.Rules.OrphanedProjects.OrphanedProjectsRule">
  <solutions searchPath="D:\Projects\Source" />
</rule>

Strong Naming

Definition

Verifies the strong naming (key signing) settings of a project file.

<rule name="StrongNamingRule" type="JelleDruyts.BuildCop.Rules.StrongNaming.StrongNamingRule">
  <strongNaming strongNameRequired="[true|false]"
                keyPath="[...]"
                ignoreUnsignedProjects="[true|false]" />
</rule>

Example

The following example verifies that all project files have strong naming enabled and that they all use the key file "D:\Projects\Source\JelleDruyts.snk".

<rule name="StrongNamingRule" type="JelleDruyts.BuildCop.Rules.StrongNaming.StrongNamingRule">
  <strongNaming strongNameRequired="true" keyPath="D:\Projects\Source\JelleDruyts.snk" ignoreUnsignedProjects="false" />
</rule>