NightOwl888 commented on issue #394: URL: https://github.com/apache/lucenenet/issues/394#issuecomment-733162314
Thanks for the report. I suspect that VS2017 requires .NET Framework < 4.6.1 or .NET Standard 1.x in order for the Analyzers to function. Unfortunately, there doesn't seem to be any documentation on how to create a multi-targeted VS analyzer package, so the simplest course of action is to use a single target. Currently, we are targeting .NET Standard 2.0 because that is the version the [latest `Microsoft.CodeAnalysis.CSharp.Workspaces` package targets](https://www.nuget.org/packages/Microsoft.CodeAnalysis.CSharp.Workspaces). It is [Microsoft's recommendation to target .NET Standard 2.0 where possible and discontinue using .NET Standard 1.x](https://docs.microsoft.com/en-us/dotnet/standard/net-standard#which-net-standard-version-to-target) because of the number of extra dependencies in .NET Standard 1.x. However, I noticed that [Xunit.Analyzers is targeting .NET Standard 1.3](https://github.com/xunit/xunit.analyzers/blob/main/src/xunit.analyzers/xunit.analyzers.csproj) and [StyleCop is targeting .NET Standard 1.1 and .NET Framework 4.5.2](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/3c877565bcfeae0e737158d7c5a7092a87ef9186/StyleCop.Analyzers/StyleCop.Analyzers/StyleCop.Analyzers.csproj), although the only assembly that is shipped via NuGet is .NET Standard 1.1. This would seem to confirm my suspicion that .NET Standard 1.x is required for multi-targeting VS2017 and VS2019. So, basically I believe the fix for VS2017 support will be: 1. Change the `TargetFramework` of [`Lucene.Net.CodeAnalysis.CSharp`](https://github.com/apache/lucenenet/blob/8ad48e7ef73c62390fc1c8f2b6ca66d60eec44a8/src/dotnet/Lucene.Net.CodeAnalysis.CSharp/Lucene.Net.CodeAnalysis.CSharp.csproj#L25) and [`Lucene.Net.CodeAnalysis.VisualBasic`](https://github.com/apache/lucenenet/blob/8ad48e7ef73c62390fc1c8f2b6ca66d60eec44a8/src/dotnet/Lucene.Net.CodeAnalysis.VisualBasic/Lucene.Net.CodeAnalysis.VisualBasic.csproj#L25) to `netstandard1.3`. 2. Change the [target version](https://github.com/apache/lucenenet/blob/8ad48e7ef73c62390fc1c8f2b6ca66d60eec44a8/build/Dependencies.props#L46-L47) of `Microsoft.CodeAnalysis.CSharp.Workspaces` and `Microsoft.CodeAnalysis.VisualBasic.Workspaces` to < 3.0.0. (unconfirmed) We would be happy to accept a PR with these changes or to discuss alternatives if this isn't a fix. ## Disabling Analyzers According to the documentation, [analyzers can be disabled for dependent projects](https://docs.microsoft.com/en-us/visualstudio/code-quality/use-roslyn-analyzers?view=vs-2019#dependent-projects). So, I suggest adding the following to your project to see if it stops the dependent projects from requiring the analyzers, also. Let us know whether this setting is helpful. ```xml <PackageReference Include="Lucene.Net" Version="4.8.0-beta00013" PrivateAssets="all" /> ``` Note that the `Lucene.Net` NuGet package is the only one with code analyzers in it. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
