dotnet / upgrade-assistant

A tool to assist developers in upgrading .NET Framework applications to .NET 6 and beyond
MIT License
1.1k stars 164 forks source link

What to do with Analyzers after upgrade? #386

Open sitty opened 3 years ago

sitty commented 3 years ago

What should be done with Microsoft.Dotnet.UpgradeAssistant.Extenstions.Default.Analyzers package after upgrade? Is it supposed to be removed? I completed upgrade of a class library and now I several warnings from different Analyzers like these Warning CS8032 An instance of analyzer Microsoft.DotNet.UpgradeAssistant.Extensions.Default.CSharp.Analyzers.AllowHtmlAttributeAnalyzer cannot be created from C:\Users\xxxx.nuget\packages\microsoft.dotnet.upgradeassistant.extensions.default.analyzers\0.2.217201\analyzers\dotnet\cs\Microsoft.DotNet.UpgradeAssistant.Extensions.Default.CSharp.Analyzers.dll: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=3.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

twsouthwick commented 3 years ago

Where are you seeing this warning? Is it in VS or .NET CLI? If so, can you share which version of the tool you're using?

sitty commented 3 years ago

I get the warnings in VS and in command line when running dotnet build. I'm using version 0.2.217201+d343ba735920891597ff387f9445430b478cf267 When I build the project in Release configuration some of these warnings show up are errors.

paulomorgado commented 3 years ago

@sitty, does the .csproj files have any PackageReference with microsoft.dotnet.upgradeassistant.*?

sitty commented 3 years ago

Yes it does <PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.2.217201">

twsouthwick commented 3 years ago

@sitty which version of VS? Sounds like we may be using too late of a version of the code analysis library when run in VS.

Upgrade Assistant will add the analyzers to your project. If you are done with them, feel free to remove them. We could look at removing them as well. However, if we were to downgrade which of code analysis library we use, they should run with no problem in VS/CLI and you won't know the difference.

sitty commented 3 years ago

I'm using Visual Studio 16.8.5

twsouthwick commented 3 years ago

Cool. So some action items for us to explore:

Either would solve the issue you raised, but probably should do both.

sitty commented 3 years ago

I can try to upgrade VS to16.9.2 and retry. I'm also getting the same warnings upon running dotnet build from terminal.

twsouthwick commented 3 years ago

We're using the latest code analysis libraries at the moment, which may be ahead of where the CLI/VS is even at. I'm interested to hear the results, though, to verify

sitty commented 3 years ago

I tested with VS 16.9.3 and I don't get these warnings.

twsouthwick commented 3 years ago

Ok - so we should look at downgrading some of our analyzer dependencies so that doesn't show up for people

sunandabalu commented 3 years ago

@twsouthwick Going to follow-up with Roslyn team on what version to downgrade to.

IEvangelist commented 3 years ago

I was going to report this as an issue, I too found it odd that a <PackageReference> that was added for part of the upgrade was left behind after the upgrade was successful. I believe it should be removed.