-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MSBuild parameter -p:RunAnalyzers=false is ignored #40926
Comments
cc @mavasani |
@foriequal0 Can you confirm if your project is importing You can also try to add the following to your targets file explicitly to get it to work:
|
@mavasani <PropertyGroup xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<CodeAnalysisTargets Condition="'$(CodeAnalysisTargets)'==''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeAnalysis\Microsoft.CodeAnalysis.targets</CodeAnalysisTargets>
</PropertyGroup>
<!--<Import Project="$(CodeAnalysisTargets)" Condition="Exists('$(CodeAnalysisTargets)')" />--> Here's a zip archive of |
Can you verify that file |
For example, on my machine, it is at |
Yes I have it at |
|
Seems to be a good reason to move the above target that I pasted into https://github.com/dotnet/roslyn/blob/master/src/Compilers/Core/MSBuildTask/Microsoft.Managed.Core.targets. I'll work on a PR. Until then, you can manually copy that MSBuild snippet into your targets file. |
Great! Thank you! I'll be looking forward to it! |
I think that issue is not specific to analyzer warnings. For example, consider the below code: public class Class1
{
void M()
{
var x = 0;
}
}
I think this is by-design for the compiler, but feel free to file a separate issue for the compiler team to triage. |
Fixes dotnet#40926 This support was added to `Microsoft.CodeAnalysis.targets` (ships with VS) in VS2019 16.5: https://docs.microsoft.com/en-us/visualstudio/code-quality/disable-code-analysis?view=vs-2019. However, the MSBuild property is not respected from 'dotnet' builds where this targets file is not imported (see dotnet#40926 (comment) for details). This change moves the disable analyzers logic down to `Microsoft.Managed.Core.targets` so it is respected for all builds.
Fixes dotnet#40926 This support was added to `Microsoft.CodeAnalysis.targets` (ships with VS) in VS2019 16.5: https://docs.microsoft.com/en-us/visualstudio/code-quality/disable-code-analysis?view=vs-2019. However, the MSBuild property is not respected from 'dotnet' builds where this targets file is not imported (see dotnet#40926 (comment) for details). This change moves the skip analyzers logic down to `Microsoft.Managed.Core.targets` and core compiler layer so it is respected for all builds. As per offline discussions with Jared and Chris, we can no longer skip analyzer execution from MSBuild by removing the "Analyzer" items as these can include source generators, which should never be skipped (at least there are no current scenarios where we want to skip generators). Hence, we are adding a new command line compiler switch `/skipAnalyzers`, optionally followed by a `+` or `-`, to allow skipping analyzers. I verified the end-to-end functionality works fine by locally building `Microsoft.Net.Compilers.Toolset.Package` NuGet package and referencing it in a project.
Version Used:
Steps to Reproduce:
-p:RunAnalyzers=false
Korean characters are mixed in the build output but I think you can get the point.
Expected Behavior:
Warnings should not be printed
Actual Behavior:
Warnings are printed. Even it can make MSBuild to return an error with
-p:TreatWarningsAsErrors=true
Also, it seems that the build warnings are not cached. If I build twice, there are no warnings in the second build. The recent release of Rust's cargo (https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#added-2) added a feature that caches build warnings. (rust-lang/cargo#7450). I prefer to separate the build step and the lint step for CI.
dotnet clean
between the steps won't be necessary if we cache warnings.The text was updated successfully, but these errors were encountered: