none
How to import the old ruleset to fxcop analyzers? RRS feed

  • Question

  • Hi,

    In my old project, I had my custom code analysis ruleset. But it always had a warning CA0507. So I install the FxCop Analyzers and set the value of RunCodeAnalysis to false. Thus my old custom ruleset did not work.

    So I want to know is there a way to import my old ruleset to the new analyzer so that I won't config that again.

    Thursday, March 5, 2020 3:04 AM

All replies

  • Hi Leon-Huiliang,
    Based on your descripton, I have a suggestion you can refer to.
    You can try to follow the steps:
    1.In Solution Explorer, right-click the project and then select Properties.
    2.On the Properties pages, select the Code Analysis tab.
    3.In the Rule Set drop-down list, select the rule set what you want to.
    4.Select Open to display the rules in the rule set editor. 
    5.Right-click and choose the Add or remove child rule set, then click the Add Rule Set button.
    6.Select your old ruleset and click OK.
    More details you can refer to this document.
    [Customize a rule set
    Hope it could be helpful for you.
    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 5, 2020 6:15 AM
  • Hi Leon-Huiliang,
    Has your problem been solved? If it is resolved, we suggest that you mark it as the answer. So it can help other people who have the same problem find a solution quickly. If not solved, what problem did you encounter?
    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 12, 2020 9:06 AM
  • Hello friend The bello article may help you

    This warning can be produced in the case when you install new analyzers Microsoft.CodeAnalysis.FxCopAnalyzers, but at the moment of installing the old analyzers were not enabled. In this case <RunCodeAnalysis>...</RunCodeAnalysis> may not exist and MSBuild takes non existence of the <RunCodeAnalysis> node as <RunCodeAnalysis>true</RunCodeAnalysis>. To fix this you have two options:

    Option 1 in IDE
    1.Open project properties.
    2.Go to the Code Analysis tab sheet
    3.In the section Binary Analyzers tick Run On Build so it is enabled.
    4.Untick Run On Build so it is disabled.
    5.Save.
    6.Build.

    You should no longer get CA0507

    Option 2 in text editor

    Manually edit your project file so the above mentioned nodes are present in all configurations. Example:

    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
     <OutputPath>bin\Debug\</OutputPath>
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <RunCodeAnalysis>false</RunCodeAnalysis>
     </PropertyGroup>
     <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
     <OutputPath>bin\Release\</OutputPath>
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <RunCodeAnalysis>false</RunCodeAnalysis>
     </PropertyGroup>

     

    For more follow the link
    https://developercommunity.visualstudio.com/content/problem/480652/several-ca0507-run-code-analysis-warnings-after-in.html

    Thursday, March 12, 2020 2:21 PM