Reported by @ViktorHofer.
Repro steps:
Error:
Must contain activeTargetFramework (.NETCoreApp,Version=v6.0).
Parameter name: dependenciesByTargetFramework
Exception:
Recoverable
System.AggregateException: Project system data flow 'DataflowBlockSlim (ActionBlockSlimAsync`1 : 17673919)' closed because of an exception: System.AggregateException: One or more errors occurred. ---> System.ArgumentException: Must contain activeTargetFramework (.NETCoreApp,Version=v6.0).
Parameter name: dependenciesByTargetFramework
at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Snapshot.DependenciesSnapshot..ctor(TargetFramework activeTargetFramework, ImmutableDictionary`2 dependenciesByTargetFramework)
at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Snapshot.DependenciesSnapshot.SetTargets(ImmutableArray`1 targetFrameworks, TargetFramework activeTargetFramework)
at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.<>c__DisplayClass32_0.<UpdateProjectContextAndSubscriptionsAsync>b__2(DependenciesSnapshot previousSnapshot)
at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.SnapshotUpdater.TryUpdate(Func`2 updateFunc, CancellationToken token)
at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.<<UpdateProjectContextAndSubscriptionsAsync>b__32_0>d.MoveNext()
Repro steps:
The evaluation fails for the System.Runtime.CompilerSerives.Unsafe project.
This might be an issue with the custom SDK in use by this project, Microsoft.NET.Sdk.IL.
We have similar issues when the TF has a suffix (e.g. net5.0-windows) but that doesn't seem to be the case here.
@ViktorHofer it's not clear that there's an action here for us to take, as it seems specific to the custom SDK and it's likely that the fix belongs there. In the .NET 5 timeframe we had a similar issue which @dsplaisted fixed in the SDK.
I'm going to close this for now.
Understood. Do you have suggestions how to root cause the exception? It's not clear to me how to identify the misbehaving part in the custom SDK.
If this is a bug in the custom SDK, there still needs to be a way to figure out what it's doing wrong.
Exactly... @drewnoakes is there a way to gather more information why the project evaluation with the custom SDK fails inside VS? cc @ericstj in case he has any ideas.
I guess we debug CPS and find out why this is hitting:
https://github.com/dotnet/project-system/blob/3643cc56303a97a39bc5b6ebc1e1db7a5a76e566/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Tree/Dependencies/Snapshot/DependenciesSnapshot.cs#L165-L171
It looks to me like dependenciesByTargetFramework is missing an entry for net6.0. Perhaps we can examine the code to find out how CPS fetches this. Perhaps we're missing a target in the IL SDK (or common targets)?
I will make a change to the error message to help diagnose this problem. It would be useful to know the set of target frameworks it expects activeTargetFramework to be in.
Thanks @drewnoakes. In addition to that, can you please help me debugging the project-system and loading the ComilerServices.Unsafe project with the custom SDK?
The problem is likely a difference in the representation of the .NET 6 TFM. There was a change made to include platform information in these strings. So where in the past you'd have .NETCoreApp,Version=v3.1, the equivalent string in .NET 5 would be net5.0 (allowing net5.0-windows, for example).
The change in #6792 will highlight such a problem more clearly.
@dsplaisted made several changes to the SDK related to these properties in .NET 5, which may be helpful:
The project system is producing the set of target frameworks, and the active target framework in AggregateCrossTargetProjectContextProvider.
I won't have time to look at this until the new year, but hopefully the above is helpful.