I've written several custom FxCop rules that I want to use with VS2005's Code Analysis engine, but I can't find any way to add-in my custom rules assembly.
I know Beta 2 doesn't have all the documentation yet, but can someone tell me how to build a custom rules assembly for VS2005 and get it installed for use in a project
Thanks!

Custom "FxCop" rules in VS 2005 Code Analysis?
d3v310p3r
VS will prefix resource names with the default namespace specified in the project, which can sometimes put you in this condition.
If you're still having problems, zip your rule assembly and send it to me. MikeFan at microsoft dot com.
Midet
Thanks for the reply Michael, that solved my problem. If the xyz.xml file is embedded into a project in the namespace a.b.xyz then "a.b.xyz.xyz" (notice 2 xyz's) needs to be passed into the base class constructor.
Thanks,
Sunil Chiluveru.
alsc
Hi,
I am same namespace at project properties default value & all classes namespace in project. Also same has mentioned in base library for project
namespace FxCopRules
{
[CLSCompliant(false)]public abstract class Rules : BaseIntrospectionRule
{
public Rules( string name ) : base(name , "FxCopRules.Rules", typeof(Rules).Assembly ) {}}
}
still getting same error.
Has anyone else found the solution for this
Regards,
asj
Niezgodka
I just checked your reply (posted earlier) for the same issue.
I have added xml file as an embedded resource and passing the correct name in the constructor as well.
I also checked with the steps as you had mentioned in your post i.e.
1. Launch FxCop
2. Load your rule assembly as an analysis target (not as a custom rule)
3. Expand the assembly node until the 'Resources' node is fully visible.
I can view the xml file under the resources node. But I am still facing the following error:
Error Loading Rule 'BaseTestRule': The following stream was not found in the assembly manifest: NtestRule.Rule.xml
Error Loading Rule 'TestRule': Error reading resource 'NtestRule.Rule.xml'
Could you please shed some light
I would appreciate your efforts.
Thanks in advance and regards,
Rajesh Khatri
dbreggin
Hi,
I too have the same problem while using FxCop. It says "unable to find the rule assembly .....". I went thru this forum so that i could get any solutions and i have cross checked everything stated here but i get the problem still. Can you help me fix this problem.
Thanks in advance and Regards,
-Rajeshsv.
Basic Veteran
Or if you want to change the rule assemblies for the entire system checkout the following file:
C:\Program Files\MSBuild\Microsoft\VisualStudio\v8.0\CodeAnalysis\Microsoft.CodeAnalysis.Targets
Juan M Acosta
FxCop can't find your rule xml resource. Are you sure you see the rule xml resource exactly as listed in FxCop's output
If you'd like to send me a zipped version of your rule I will take a look. I think we can take FxCop's output at face value here, there is simply a mismatch between the name that you've specified in the rule constructor and the xml name that's embedded in the assembly.
Garon Line
There are others on this forum (and in the VS Team System Developer forum) who have gotten this working, however, perhaps someone will see this request and post a sample.
Andria1974
hi
I am trying to create custom rules for FxCop application. I have created custom rule DLLs. While loading the rules, I get the below message:
---------
Check for updates on startup is currently disabled.
To enable, select "Settings..." from the Tools and check "Check for updates to FxCop on startup".
Error loading rule 'AvoidComplicatedMethods':The following stream was not found in the assembly manifest: FxCop.Rules.Rules.xml
* The following stream was not found in the assembly manifest: FxCop.Rules.Rules.xml
Unable to load rule assembly 'D:\FxCop\samples\Test\Test\bin\Release\Test.dll'.
at Microsoft.Tools.FxCop.Common.EngineManager.StandardLoadRules(RuleFile ruleFile)
at Microsoft.Tools.FxCop.Common.EngineManager.LoadRules(RuleFile ruleFile)
at Microsoft.Tools.FxCop.Common.RuleFile..ctor(String fileName, RuleFileDictionary container)
----------
I have included the XML file in the project and set the "Build action" property as "Embedded resource". Even then I get the above error message.
Kindly let me know the steps for creating and adding custom rule in details. I would be very greatful.
Expecting reply from anyone ASAP.
Thanks
Rajesh
Glenn0305
I also encountered the same problem. After some thorough examination I found that the default namespace of the DLL in project properties was different from the names space I was using for rules class. If you make them same and compile the application, this error will not be displayed any longer.
Thanks
Darla
Bill Tubbs
When using an alternate location, you'd need to go with the approach David mentions.
Michael
S. Khawar
Rajesh,
I ran into the same problem ([...]The following stream was not found in the assembly manifest[...]).
Did you (or anyone else) find a solution for FxCop 1.32
Regards,
// Martin Rosen-Lidholm
leovic0101
1. Launch FxCop
2. Load your rule assembly as an analysis target (not as a custom rule)
3. Expand the assembly node until the 'Resources' node is fully visible.
According to the code you posted, you should see an item named 'FxCopRules.Rules.xml'. I am guessing you will not. If I am right, you either need to correct your base class to pass the correct resource name (which should map exactly to the embedded resource, without the '.xml' extension) or you need to change your compilation step to embed the XML with the correct naming pattern. This can be done directly on the csc.exe command-line or can be configured in VS.
Michael Fanning
VSTS Development: Code Analysis