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>
assemblyLocations
: contains 0 or more assemblyLocation
nodes.assemblyLocation
: defines an expected assembly location.
assemblyName
: the fully qualified assembly name to verify (or at least
the start of it).assemblyPath
: the expected location of the assembly (or at least the
start of it).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>
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>
buildProperties
: contains 0 or more buildProperty
nodes.buildProperty
: defines an expected build property.
name
: the name of the build property.value
(optional): the expected value of the build property.condition
(optional): the condition (or a part of it) that should be
present in the build property's condition; typically used to differentiate between
"Debug" and "Release" solution configurations, which are represented as MSBuild
conditions.compareOption
(optional): the comparison option to use when checking
build property values.
EqualTo
: the build property's value must be exactly equal to the given
value.NotEqualTo
: the build property's value may not be exactly equal to
the given value.Exists
: the build property must exist (and can have any value).DoesNotExist
: the build property may not exist.In
: the build property's value must appear anywhere in the given value.NotIn
: the build property's value may not appear anywhere in the given
value.stringCompareOption
(optional): the comparison option to use when comparing
strings; typically used to make the comparison case insensitive.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>
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.
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" />
Verifies that certain naming conventions are respected.
<rule name="NamingConventionsRule" type="JelleDruyts.BuildCop.Rules.NamingConventions.NamingConventionsRule"> <prefixes namespacePrefix="[...]" assemblyNamePrefix="[...]" assemblyNameShouldMatchRootNamespace="[true|false]" /> </rule>
prefixes
: defines naming conventions for certain prefixes.
namespacePrefix
(optional): the expected root namespace of the project
(or at least the start of it).assemblyNamePrefix
(optional): the expected assembly name of the project
(or at least the start of it).assemblyNameShouldMatchRootNamespace
(optional): a value of "true"
or "false" that determines if the assembly name must be the same as the root namespace.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>
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>
solutions
: defines where to look for Visual Studio solution (.sln)
files.
searchPath
: the root path in which to recursively look for solution
files.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>
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>
strongNaming
: defines the expected settings for strong naming assemblies.
strongNameRequired
: a value of "true" or "false" that determines if
strong naming should be enabled.keyPath
(optional): if a strong name is required, determines the path
to the key file that should be used to sign the assembly.ignoreUnsignedProjects
(optional): a value of "true" or "false" that
determines if projects that don't have strong naming enabled should be ignored;
this can be used to check only that the key being used is valid for projects that
do have strong naming enabled.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>