How to get rid of the errors CA0055 and CA0052

During the last weeks, some users were complaining about the error messages CA0055 and CA0052, which will be reported by the Power Tool, if an invalid target file is specified. The extension tries to obtain the assembly filename from the project file by using MSBuild property evaluation (it´s looking for the TargetPath-property). In some situations, the property evaluation fails, if the OutputPath- and PlatformTarget-property is not specified. In that case, the evaluated value of the TargetPath-property will only contain the name of the output assembly file, but not the full path.

I couldn´t simulate that behavior just by making changes to the build configuration or project properties of projects created by Visual Studio 2010, but I have seen that behavior in some older projects which were created using the 2005/2008 version and upgraded to a Visual Studio 2010 solution. The interesting thing is that this problem can´t be fixed by cleaning-up build- and platform configuration using the Visual Studio dialogs because Visual Studio won´t change any customized (or manually added) elements within the project file (which is good). So, we have to fix this problem by manually editing the project file… Don´t worry – this is quite easy (-:

Open the project file using an editor of your choice… if you´re using Power Commands for Visual Studio, you can use the “Edit Project File” command. You´ll find a property group containing an element named “Platform” having a condition, which ensures that a valid value is specified. In the following example the value “x86” will be used, if the property is empty (correct me, if I am wrong, but I think this is the default configuration for Windows Forms and WPF applications created by Visual Studio 2010).

  
    Debug
    x86
    8.0.30703
    2.0
    {E1FAB955-3610-4315-BE54-DAF9EE9F4533}
    WinExe
    Properties
    WindowsFormsApplication1
    WindowsFormsApplication1
    v4.0
    Client
    512
  

Okay; this will work if you have another property group like this…

  
    true
    bin\Debug\
    DEBUG;TRACE
    full
    AnyCPU
    prompt
    true
    true
  

This property group depends on the Platform- and Configuration properties defined earlier; if the values are “x86” and “Debug”, the properties of this group will be defined and can be evaluated by MSBuild. If you´re using a different platform configuration like “Any CPU” and/or “Release”, the evaluation will fail and the Power Tool can´t analyze the assembly. Notice that Platform and PlatformTarget are not the same (-:

Depending on your build configuration, you can add more property groups having different conditions. For example…

  
    true
    bin\Debug\
    DEBUG;TRACE
    full
    AnyCPU
    prompt
    true
    true
  
  
    bin\Release\
    TRACE
    true
    pdbonly
    AnyCPU
    prompt
    true
    true
  

To cut a long story short: Make sure, that you´ve defined at least one property group that matches the default values of the Configuration- and Platform properties. This property group must contain the OutputPath- and PlatformTarget-properties. A good verification of the project file is to build it using MSBuild from the command line (without any additional switches).

So, now it´s up to you to fix your project file(s)…

How to get results for code behind XAML-files

In June, a user reported a problem where he does not see any results for code-behind XAML files. I dove into the problem and figured out that code-behind XAML files were handled by the power tool like generated code, which I had disabled by default using the /igc switch. The latest version of the tool allows you to take control over the switch; if you want to calculate code metrics for generated code you have to make sure, that the /igc option is disabled.