dotnet / upgrade-assistant

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

Startup step to fail fast if net5.0 sdk not present #663

Open Wraiyth opened 3 years ago

Wraiyth commented 3 years ago

Describe the bug

After installing and running the upgrade assistant, there's an exception thrown instantly

[13:19:54 INF] Applying upgrade step Select project to upgrade
[13:19:54 ERR] Unexpected error applying step
System.MissingMethodException: Method not found: 'System.String NuGet.Frameworks.NuGetFramework.get_Platform()'.
   at Microsoft.DotNet.UpgradeAssistant.MSBuild.NuGetTargetFrameworkMonikerComparer.TryParse(String input, TargetFrameworkMoniker& tfm)
   at Microsoft.DotNet.UpgradeAssistant.MSBuild.TargetFrameworkMonikerCollection.GetEnumerator()+MoveNext() in /_/src/components/Microsoft.DotNet.UpgradeAssistant.MSBuild/TargetFrameworkMonikerCollection.cs:line 78
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
   at Microsoft.DotNet.UpgradeAssistant.Checks.MultiTargetFrameworkCheck.IsReadyAsync(IProject project, UpgradeReadinessOptions options, CancellationToken token) in /_/src/components/Microsoft.DotNet.UpgradeAssistant/Checks/MultiTargetFrameworkCheck.cs:line 43
   at Microsoft.DotNet.UpgradeAssistant.Steps.Solution.CurrentProjectSelectionStep.RunChecksAsync(IProject project, CancellationToken token)
   at Microsoft.DotNet.UpgradeAssistant.Steps.Solution.CurrentProjectSelectionStep.<>c__DisplayClass22_0.<<GetProjectAsync>g__CreateProjectCommandAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.DotNet.UpgradeAssistant.Steps.Solution.CurrentProjectSelectionStep.GetProjectAsync(IUpgradeContext context, CancellationToken token)
   at Microsoft.DotNet.UpgradeAssistant.Steps.Solution.CurrentProjectSelectionStep.ApplyImplAsync(IUpgradeContext context, CancellationToken token)
   at Microsoft.DotNet.UpgradeAssistant.UpgradeStep.ApplyAsync(IUpgradeContext context, CancellationToken token) in /_/src/common/Microsoft.DotNet.UpgradeAssistant.Abstractions/UpgradeStep.cs:line 170
Command (Apply next step (Select project to upgrade)) did not succeed

To Reproduce

Run on any project

Exceptions (if any)

Further technical details

0.2.231403+ee9618b1fb94a6881a2e38a7b2ad50356ba54465

Wraiyth commented 3 years ago

Just in further testing, this seemed to be a weird .NET version issue, once I installed .NET 5.0 SDK it seems to work.

twsouthwick commented 3 years ago

What msbuild version is it selecting (the log file/log output should show that)? Can you try removing the v5 preview and installing a stable version of it? I believe by default we ignore preview versions, so I'm betting you're using 3.1.410

twsouthwick commented 3 years ago

@sunandabalu we should verify people are at least using v5 of the SDK - we're expecting to loadNuGet and MSBuild from the SDK and we're compiling against a v5 version of it.

sunandabalu commented 3 years ago

@sunandabalu we should verify people are at least using v5 of the SDK - we're expecting to loadNuGet and MSBuild from the SDK and we're compiling against a v5 version of it.

Yeah an initial startup step that fails with more info on what version to use would be helpful