Skip to main content
Version: v3

WixCop

WixCop serves two main purposes:

  • To upgrade WiX authoring to the current schema
  • To format WiX authoring according to a set of common formatting

WixCop's command-line syntax is:

WixCop.exe [options] sourceFile [sourceFile ...]

WixCop takes any number of WiX source files as command-line arguments. Wildcards are permitted. WixCop supports response files containing options and source files, using @responseFile syntax.

WixCop returns the following exit codes:

  • 0, when no errors are reported.
  • 1, when a fatal error occurs.
  • 2, when WixCop violations occur.

The following table describes the switches that WixCop supports.

WixCop switchDescription
-?Show help.
-nologoDon't show the WixCop banner.
-fFix errors encountered in source files. This switch takes effect only for source files that are writable.
-sLook for source files in subdirectories.
-indent:nOverrides the default number of spaces per indentation level (4) to the number n you specify.
-set1filenameLoads a primary settings file (see below). Note that there are no characters separating -set1 and the settings file name.
-set2filenameLoads an alternate settings file that overrides some or all of the settings in the primary settings file. Note that there are no characters separating -set2 and the settings file name.

WixCop settings files

WixCop supports two settings files. Generally, the primary settings file is your global settings and the alternate settings file lets you override the global settings for a particular project.

Settings files are XML with the following structure:

<Settings>
<IgnoreErrors>
<Test Id="testId" />
</IgnoreErrors>
<ErrorsAsWarnings>
<Test Id="testId" />
</ErrorsAsWarnings>
<ExemptFiles>
<File Name="foo.wxs" />
</ExemptFiles>
</Settings>

The IgnoreErrors element lists test IDs that should be ignored. The ErrorsAsWarnings element lists test IDs that should be demoted from errors to warnings. The ExemptFiles element lists files that should be skipped. The following table describes the tests that WixCop supports.

WixCop test IDDescription
UnknownInternal only: returned when a string cannot be converted to an InspectorTestType.
InspectorTestTypeUnknownInternal only: displayed when a string cannot be converted to an InspectorTestType.
XmlExceptionDisplayed when an XML loading exception has occurred.
UnauthorizedAccessExceptionDisplayed when a file cannot be accessed; typically when trying to save back a fixed file.
DeclarationEncodingWrongDisplayed when the encoding attribute in the XML declaration is not 'UTF-8'.
DeclarationMissingDisplayed when the XML declaration is missing from the source file.
WhitespacePrecedingCDATAWrongDisplayed when the whitespace preceding a CDATA node is wrong.
WhitespacePrecedingNodeWrongDisplayed when the whitespace preceding a node is wrong.
NotEmptyElementDisplayed when an element is not empty as it should be.
WhitespaceFollowingCDATAWrongDisplayed when the whitespace following a CDATA node is wrong.
WhitespacePrecedingEndElementWrongDisplayed when the whitespace preceding an end element is wrong.
XmlnsMissingDisplayed when the xmlns attribute is missing from the document element.
XmlnsValueWrongDisplayed when the xmlns attribute on the document element is wrong.
CategoryAppDataEmptyDisplayed when a Category element has an empty AppData attribute.
COMRegistrationTyperDisplayed when a Registry element encounters an error while being converted to a strongly-typed WiX COM element.
UpgradeVersionRemoveFeaturesEmptyDisplayed when an UpgradeVersion element has an empty RemoveFeatures attribute.
FeatureFollowParentDeprecatedDisplayed when a Feature element contains the deprecated FollowParent attribute.
RadioButtonMissingValueDisplayed when a RadioButton element is missing the Value attribute.
TypeLibDescriptionEmptyDisplayed when a TypeLib element contains a Description element with an empty string value.
ClassRelativePathMustBeAdvertisedDisplayed when a RelativePath attribute occurs on an unadvertised Class element.
ClassDescriptionEmptyDisplayed when a Class element has an empty Description attribute.
ServiceInstallLocalGroupEmptyDisplayed when a ServiceInstall element has an empty LocalGroup attribute.
ServiceInstallPasswordEmptyDisplayed when a ServiceInstall element has an empty Password attribute.
ShortcutWorkingDirectoryEmptyDisplayed when a Shortcut element has an empty WorkingDirectory attribute.
IniFileValueEmptyDisplayed when a IniFile element has an empty Value attribute.
FileSearchNamesCombinedDisplayed when a FileSearch element has a Name attribute that contains both the short and long versions of the file name.
WebApplicationExtensionIdDeprecatedDisplayed when a WebApplicationExtension element has a deprecated Id attribute.
WebApplicationExtensionIdEmptyDisplayed when a WebApplicationExtension element has an empty Id attribute.
PropertyValueEmptyDisplayed when a Property element has an empty Value attribute.
ControlCheckBoxValueEmptyDisplayed when a Control element has an empty CheckBoxValue attribute.
RadioGroupDeprecatedDisplayed when a deprecated RadioGroup element is found.
ProgressTextTemplateEmptyDisplayed when a Progress element has an empty TextTemplate attribute.
RegistrySearchTypeRegistryDeprecatedDisplayed when a RegistrySearch element has a Type attribute set to 'registry'.
WebFilterLoadOrderIncorrectDisplayed when a WebFilter/@LoadOrder attribute has a value that is not more stongly typed.
SrcIsDeprecatedDisplayed when an element contains a deprecated src attribute.
RequireComponentGuidDisplayed when a Component element is missing the required Guid attribute.
LongNameDeprecatedDisplayed when a an element has a LongName attribute.
RemoveFileNameRequiredDisplayed when a RemoveFile element has no Name or LongName attribute.
DeprecatedLocalizationVariablePrefixDisplayed when a localization variable begins with the deprecated '$' character.
NamespaceChangedDisplayed when the namespace of an element has changed.
UpgradeVersionPropertyAttributeRequiredDisplayed when an UpgradeVersion element is missing the required Property attribute.
UpgradePropertyChildDisplayed when an Upgrade element contains a deprecated Property child element.
RegistryElementDeprecatedDisplayed when a deprecated Registry element is found.
PatchSequenceSupersedeTypeChangedDisplayed when a PatchSequence/@Supersede attribute contains a deprecated integer value.
PatchSequenceTargetDeprecatedDisplayed when a deprecated PatchSequence/@Target attribute is found.
VerbTargetDeprecatedDisplayed when a deprecated Verb/@Target attribute is found.
ProgIdIconFormattedDisplayed when a ProgId/@Icon attribute value contains a formatted string.
IgnoreModularizationDeprecatedDisplayed when a deprecated IgnoreModularization element is found.
PackageCompressedIllegalDisplayed when a Package/@Compressed attribute is found under a Module element.
PackagePlatformsDeprecatedDisplayed when a Package/@Platforms attribute is found.
ModuleGuidDeprecatedDisplayed when a deprecated Module/@Guid attribute is found.
GuidWildcardDeprecatedDisplayed when a deprecated guid wildcard value is found.
FragmentRefIllegalDisplayed when a FragmentRef Element is found.
FileRedundantNamesDisplayed when a `File/@Name` matches a `File/@ShortName`.