Sdk: The Run Code Analysis function is missing in Visual Studio 2017 when using new csproj format.

Created on 6 Apr 2017  路  8Comments  路  Source: dotnet/sdk

I want to use the Visual Studio Code analyser for my new .netstandard libray project. But when I right click on the project there is no analyse menu item anymore. It seems that all projects which use the new csproj formats cannot be analysed with the analyser.

Is this known?

Update:

If I add the following to the csproj file:

<RunCodeAnalysis>true</RunCodeAnalysis> <CodeAnalysisRuleSet>...</CodeAnalysisRuleSet>

and when I then build the project with MSBuild 15 it will run the code anaysis and generates the following warning:

_MSBUILD : warning : CA0068 : Debug information could not be found for target assembly 'CodeAnalyseTest.dll'. For b est analysis results, include the .pdb file with debug information for 'CodeAnalyseTest.dll' in the same directory a s the target assembly._

But the .pdb is there. When I add now a

<DebugType>Full</DebugType>

to the csproj and then rebuild it with msbuild the code analyse works well.
But why is it impossible to do this with Visual Studio?

Update2:
If I add the RunCodeAnalysis tag to the project file then it will run the analysis on each build even in Visual Studio. But this is not what I want. I want to choose when I the analyse has to run.

Most helpful comment

So is it possible to run the same analyser rules with Roslyn now? I cannot find any help for doing such thing.

@jinujoseph was talking about writing a doc about that.

it is possible to run the analyser for netstandard libraries as you can see in my first post. It is only the visual studio integration which is missing.

Ah yes for netstandard it might work but I believe it is broken for netcore. Either way it's not tested and

But what about Visual Studio code analyser, does it get updates/fixes or is the focus only by roslyn analyser?

The plan is to update the VS code analysis experience to be powered by Roslyn.

All 8 comments

@srivatsn @davkean @AnthonyDGreen Do we have guidance on how to set up Roslyn Analyzers to replace code analysis?

This would be nice. So is the Visual Studio Code Analysis dead? And we should take Roslyn Analyser instead?

The implementation behind VS's CodeAnalysis feature is being replaced. It used to work by doing binary analysis (FxCop) and it is going to be switched to doing source analysis using Roslyn analyzers. So the scenario\experience is not dead - just the old analysis engine which doesn't support netstandard.
@jinujoseph @mavasani

So is it possible to run the same analyser rules with Roslyn now? I cannot find any help for doing such thing.
And why do you say

just the old analysis engine which doesn't support netstandard.

it is possible to run the analyser for netstandard libraries as you can see in my first post. It is only the visual studio integration which is missing.

But what about Visual Studio code analyser, does it get updates/fixes or is the focus only by roslyn analyser?

Thank you for your help.

So is it possible to run the same analyser rules with Roslyn now? I cannot find any help for doing such thing.

@jinujoseph was talking about writing a doc about that.

it is possible to run the analyser for netstandard libraries as you can see in my first post. It is only the visual studio integration which is missing.

Ah yes for netstandard it might work but I believe it is broken for netcore. Either way it's not tested and

But what about Visual Studio code analyser, does it get updates/fixes or is the focus only by roslyn analyser?

The plan is to update the VS code analysis experience to be powered by Roslyn.

@jinujoseph is this something that you can take over? Thanks!

I believe Code Metrics has the same issue.

Was this page helpful?
0 / 5 - 0 ratings