dotnet / project-system

The .NET Project System for Visual Studio
MIT License
972 stars 389 forks source link

Critical capabilities changes were detected without any change made to the project #3673

Open davkean opened 6 years ago

davkean commented 6 years ago

From @vsfeedback on June 16, 2018 15:5

  1. git clone https://github.com/dotnet/docfx.git
  2. open the All.sln
  3. error: The project system has encountered an error.

Internal error: Critical capabilities changes were detected without any change made to the project 'Microsoft.DocAsCode.Metadata.ManagedReference.FSharp.Tests.fsproj', and forces the project to be reloaded. Potential capabilities involved: 'FSharp'.

I meet this error after upgrading to vs 15.7.3. I found several issues with similar error message that have been fixed in 15.3, but I think it's not the same issue for me.

Details:

LimitedFunctionality
System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Internal error: Critical capabilities changes were detected without any change made to the project 'Microsoft.DocAsCode.Metadata.ManagedReference.FSharp.fsproj', and forces the project to be reloaded.  Potential capabilities involved: 'FSharp'.
   at Microsoft.VisualStudio.ProjectSystem.ProjectCapabilitiesRequirementsService.<RequestReloadForIncompatibleCapabilitiesAsync>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex)
   at Microsoft.VisualStudio.ProjectSystem.ProjectErrorReporting.<>c__DisplayClass6_0.<SubmitErrorReport>b__0()
   at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.<Guard>b__0()
   at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.InvalidOperationException: Internal error: Critical capabilities changes were detected without any change made to the project 'Microsoft.DocAsCode.Metadata.ManagedReference.FSharp.fsproj', and forces the project to be reloaded.  Potential capabilities involved: 'FSharp'.
   at Microsoft.VisualStudio.ProjectSystem.ProjectCapabilitiesRequirementsService.<RequestReloadForIncompatibleCapabilitiesAsync>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex)
   at Microsoft.VisualStudio.ProjectSystem.ProjectErrorReporting.<>c__DisplayClass6_0.<SubmitErrorReport>b__0()
   at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.<Guard>b__0()
   at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)<---

This issue has been moved from https://developercommunity.visualstudio.com/content/problem/267201/critical-capabilities-changes-were-detected-withou-1.html VSTS ticketId: 626735 These are the original issue comments: (no comments) These are the original issue solutions: (no solutions)

Copied from original issue: Microsoft/visualfsharp#5205

davkean commented 6 years ago

From @cartermp on June 16, 2018 15:6

This might need to go under dotnet/project-system

davkean commented 6 years ago

From @cartermp on June 18, 2018 17:28

@TIHan FYI

davkean commented 6 years ago

This line here: https://github.com/dotnet/project-system/blob/master/src/Microsoft.VisualStudio.ProjectSystem.FSharp.VS/Packaging/FSharpProjectSystemPackage.cs#L23 is supposed to prevent this capability from being "dynamic" (comes and going based on what packages/targets are installed).

davkean commented 6 years ago

I can repro 100% on 15.7, cannot repro on 15.8.

davkean commented 6 years ago

Okay I know the cause, these projects aren't real F# projects. They are C# projects that someone has renamed to fsproj. When loading, they start off as "CSharp" due the C# factory in the solution, and only latter when we evaluate the project does the "FSharp" capability arrive from targets files. We have F# components that must be loaded during startup, hence critical capability, - so CPS faults.

The fix is for someone to File -> New F# project and add it manually to the solution. The solution is currently telling VS that the project should be loaded using "C#" project system.

I'll leave this bug open, as I'd like for us to handle this situation better - it's kind odd/powerful that we don't care about the extension of the project at all when determining the default set of capabilities.

davkean commented 6 years ago

tag @superyyrrzz on this version.

davkean commented 6 years ago

I thinking maybe we should just Veto the load if the expected "default" capabilities aren't present (but we need at least one?) via IVetoProjectPreLoad or always force default capabilities based on extension.

superyyrrzz commented 6 years ago

@davkean Thank you for the information! I will try the fix.