FxCop integration in Visual Studio 2005 Standard or Professional
FxCop is a free Microsoft utility that analyses compiled .Net code and makes suggestion based on rules, may them be design, security, performance of company policy rules.
The first problem is that you can only use it on compiled code. That means executables and DLLs. But what about ASP.Net 2.0? It doesn't build a DLL anymore, like 1.1 did. How can one use it? I have built an application (one that you will have to message me to send to you) that takes the project name as a parameter and then creates an FxCop project file with the DLLs from the site bin folder as reference DLLs and the DLLs from the Asp.Net temporary folder of that project as analysis targets. That means that you can also use it for ASP.Net now.
The second problem is that FxCop is now part of Team System, the overpriced and overhyped version of Visual Studio, and any attempts to use it with the Standard or Professional versions are cumbersome and undocumented. Siderite to the rescue! Here is a quick way to integrate FxCop as an external tool to Visual Studio and use it for either Console and Windows Forms applications or Asp.NET sites.
Step 1. Download FxCop. The latest version is 1.35, but there is also a 1.36 beta available that knows about lambda expressions and stuff like that.
Step 2. Get from me the FxCopAspNet application (completely free and with source), or build your own. Here is a possibly working link for it: at MediaFire.
Step 3. Open Visual Studio, go to Tools/External Tools and add two FxCop entries:
- FxCop [use C:\Program Files\Microsoft FxCop 1.36\fxcop.exe as Command, "$(TargetPath)" as Arguments and C:\Program Files\Microsoft FxCop 1.36 as Initial Directory]
- FxCopAspNet [use C:\Program Files\FxCopAspNet\FxCopAspNet.exe as Command, "$(ProjectFileName)" as arguments and C:\Program Files\FxCopAspNet as Initial Directory]
Step 4. Just open your web site or application in Visual Studio, compile it, then click on the FxCop item that applies.
Now, this is not meant to be a tutorial on FxCop, here are some links that might enlighten people:
Download FxCop 1.36 Beta
Download FxCop 1.35
Open Source FxCop Integration Add-in for Visual Studio 2005
How to copy the necessary files from Team System to Visual Studio 2005 Professional to make integration work
Use FxCop from your own code
A small tutorial
FxCopUnit, FxCop testing unit project
Video on how to create your own FxCop rules
There are a myriad rules included in the default installation of FxCop, some of them are just annoying, like some naming rules or some telling you you shouldn't raise Exceptions just objects inherited from Exception, but some are pretty good. A lot more can be found on the Internet and now, with the integration in VS Team System, I expect a lot more to pop-up.
The first problem is that you can only use it on compiled code. That means executables and DLLs. But what about ASP.Net 2.0? It doesn't build a DLL anymore, like 1.1 did. How can one use it? I have built an application (one that you will have to message me to send to you) that takes the project name as a parameter and then creates an FxCop project file with the DLLs from the site bin folder as reference DLLs and the DLLs from the Asp.Net temporary folder of that project as analysis targets. That means that you can also use it for ASP.Net now.
The second problem is that FxCop is now part of Team System, the overpriced and overhyped version of Visual Studio, and any attempts to use it with the Standard or Professional versions are cumbersome and undocumented. Siderite to the rescue! Here is a quick way to integrate FxCop as an external tool to Visual Studio and use it for either Console and Windows Forms applications or Asp.NET sites.
Step 1. Download FxCop. The latest version is 1.35, but there is also a 1.36 beta available that knows about lambda expressions and stuff like that.
Step 2. Get from me the FxCopAspNet application (completely free and with source), or build your own. Here is a possibly working link for it: at MediaFire.
Step 3. Open Visual Studio, go to Tools/External Tools and add two FxCop entries:
- FxCop [use C:\Program Files\Microsoft FxCop 1.36\fxcop.exe as Command, "$(TargetPath)" as Arguments and C:\Program Files\Microsoft FxCop 1.36 as Initial Directory]
- FxCopAspNet [use C:\Program Files\FxCopAspNet\FxCopAspNet.exe as Command, "$(ProjectFileName)" as arguments and C:\Program Files\FxCopAspNet as Initial Directory]
Step 4. Just open your web site or application in Visual Studio, compile it, then click on the FxCop item that applies.
Now, this is not meant to be a tutorial on FxCop, here are some links that might enlighten people:
Download FxCop 1.36 Beta
Download FxCop 1.35
Open Source FxCop Integration Add-in for Visual Studio 2005
How to copy the necessary files from Team System to Visual Studio 2005 Professional to make integration work
Use FxCop from your own code
A small tutorial
FxCopUnit, FxCop testing unit project
Video on how to create your own FxCop rules
There are a myriad rules included in the default installation of FxCop, some of them are just annoying, like some naming rules or some telling you you shouldn't raise Exceptions just objects inherited from Exception, but some are pretty good. A lot more can be found on the Internet and now, with the integration in VS Team System, I expect a lot more to pop-up.
Comments
Sorry. The archive now contains the elusive template.xml
SideriteFxCopAsp.exe complaining about missing template.xml? was this supposed to be included in the download?
JaxI will try to post it somewhere public today. Maybe one of those free ad-driven download sites. Will comment when it is done.
SideriteCan you send me that FxCopAspNet application?
z960849