Can't run code analysis using MSBuild for .NET Core 2.0 / .NET Standard 2.0 projects
Hello,
I'm using Visual Studio Enterprise 2017 Preview Version 15.3.0 Preview 4.0 (VisualStudio.15.Preview/15.3.0-pre.4.0+26711.1)
When I try to run code analysis using MSBuild for any .NET Core 2.0 or .NET Standard 2.0 projects using a command like this:
msbuild /p:RunCodeAnalysis=true netcore2ClassLibrary1.csproj
I'm getting the following errors:
Running Code Analysis... MSBUILD : error : CA0055 : Could not identify platform for 'E:\Source\Temp\NetS tandardClassLibrary1\netcore2ClassLibrary1\bin\Debug\netcoreapp2.0\netcore2Clas sLibrary1.dll'. [E:\Source\Temp\NetStandardClassLibrary1\netcore2ClassLibrary1
netcore2ClassLibrary1.csproj] MSBUILD : error : CA0052 : No targets were selected. [E:\Source\Temp\NetStandar dClassLibrary1\netcore2ClassLibrary1\netcore2ClassLibrary1.csproj] Code Analysis Complete -- 2 error(s), 0 warning(s)
Is this an expected behaviour? If yes, is there any other way to run code analysis for .NET Core/Standard 2.0 projects from a command line and produce the same kind of CodeAnalysisLog.xml file which is produced by MSBuild for .NET Framework projects? (I need it for our CI, for a solution which consists of a large set of old .NET Framework projects and some new .NET Standard projects as well)
Thanks Max
@mizbrodin I have this problem, too,but I think you can use jetbrains rider instead。did you solved the problem?
@mokeyish I don't have a solution for this problem yet. Our company doesn't have a license for JetBrains Rider and, at the moment, I don't know anything about this IDE and its build tools. We have Visual Studio Enterprise licenses as part of our MSDN Subscription and I'd prefer to be able to use MSBuild for running code analysis in our CI build configuration as we do it for other projects.
Hi All, We are facing similar issue. Any workaround or solution, Also I additional observation, while compile with "netstandard2.0" as "TargetFramework", generated assembly Platform Target coming as Unknown while with "netstandard1.4" its coming as "Windows Runtime".
Same issue here. It seems to me static code analysis is very fuzzy, or I just used to the existing full framework FxCop solution
Same issue here.
Same problem.
same issue here.
I have Visual Studio 2017 (15.2) and a .NetStandard core library project.
- If the project is targeted for 1.4 and I run MSBuild.exe then everything works
- If the project is targeted for 1.5 and I run MSBuild.exe then I get this error: MSBUILD : error : CA0055 : Coult not identify platform for "...dll path..."
Are there any plans to address this? Any other options for running FxCop against .NET core projects?
I have a feeling that Microsoft will not continue to support FxCop. Rather, it's expected that you install Microsoft.CodeAnalysis.FxCopAnalyzers NuGet package to your solution and it will run the code analysis via Roslyn API. Actually, they are cooler than FxCop as they:
- work quicker;
- provide feedback instantly (highlight errors while you are typing);
- provide quick fixes.
See more detail here: https://github.com/dotnet/roslyn-analyzers.
Notice, not all the analyzers have been already ported, so it might still make sense to run code analysis for the supported frameworks (e.g. net 452).
@zvirja Do you know if the Nuget package respects the CodeAnalysis MSBuild configuration settings like <RunCodeAnalysis>false</RunCodeAnalysis>, CodeAnalysis dictionarys and the ruleset files?
I've used this package in the AutoFixture project and it seems to respect everything you mentioned.
@zvirja is correct. The path forward is the Microsoft.CodeAnalysis.FxCopAnalyzers NuGet package. A large portion of the rules have been moved over to analyzers. FXCop was a solution implemented before the richness of the new C# compiler existed.
Thanks all I'll give the package a try today.
Sounds good. I'm going to close this for now but we can re-open this if it doesn't work.
Please let me know Is this CA0055 and CA0052 issues got resolved for .Net Core 2.0 (netcoreapp2.0) projects?
Asking this because I'm still getting these errors when enabled our .Net Core 2.0 projects to use code analysis ruleset which are defined for our projects and trying to build from Visual Studio 2017 (updated to 15.3.5 version) and by using MSBuild command.
As per this conversion thread, I've installed Nuget package of Microsoft.CodeAnalysis.FxCopAnalyzers to our .net core 2.0 projects, but still getting CA0055 and CA0052 errors. Please help me out to resolve these issues which are blocking our builds.
@dvm-2k1 I opened an issue for you here: https://github.com/dotnet/roslyn-analyzers/issues/1313
Thats is the best place to get help for that specific issue.
same here.
@Petermarcu has anyone committed to fixing this issue?
Why is this issue closed? It's still a problem.
The other closed issue says that we need to install a NuGet package and compile at the command line.
Is anyone actually bothering to fix the problem inside Visual Studio?
This is still an issue.