I have users using both Visual Studio and FxCop, and I want to create custom rules that run on both. Is this possible?
Although in the future we do plan on making it easier to move custom rules between Visual Studio and FxCop, currently you must recompile each rule assembly against the version of FxCop/Visual Studio you want to target.
Typically this involves the (painful) step of manually removing, and re-adding the references to both FxCopSdk.dll and Microsoft.Cci.dll.
To improve this process, we have developed an MSBuild targets files that can be imported by your custom rules projects, which makes switching between targetting FxCop 1.35 and Visual Studio as easy as changing build configurations.
In the attached download, the same sample rules project that was made available here, has been included, however, it has been updated to import this new targets file. This project has 4 build configurations, FxCopDebug, FxCopRelease, VisualStudioDebug and VisualStudioRelease. As you can probably guess from the names, the former two target building against FxCop, while the later two target building against Visual Studio. You can use this project as a starting base, or follow the below steps to import this targets file in your own projects:
Once you have done the above, switching the active build configuration between FxCopDebug and VisualStudioDebug will now also change the references to FxCopSdk and Microsoft.Cci to point to the associated version.
If you have any issues with the Microsoft.CodeAnalysis.CustomRules.targets file, or with the custom rules themselves, don't hesitate to visit the FxCop forum.