question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Visual Studio running into some problems while loading the Csproj with custm TargetPlatform

See original GitHub issue

Visual Studio Version: Microsoft Visual Studio Enterprise 2019 Int Preview Version 16.9.0 Preview 1.0 [30601.220.main]

Summary Build is still working but the VS gives a warning that some of the functions might not work

Steps to Reproduce:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>net5.0;net5.0-WindowsLKG</TargetFrameworks>
    <TargetPlatformSupported>true</TargetPlatformSupported>
    <TargetPlatformVersionSupported>true</TargetPlatformVersionSupported>
  </PropertyGroup>
  <PropertyGroup Condition="'$(TargetFramework)' == 'net5.0-WindowsLKG'">
    <TargetPlatformIdentifier>Unix</TargetPlatformIdentifier>
    <TargetPlatformVersion>8.0</TargetPlatformVersion>
  </PropertyGroup>
</Project>

Error

Must contain activeTargetFramework (.NETCoreApp,Version=v5.0). Parameter name: dependenciesByTargetFramework

Log

=====================
10/6/2020 3:18:36 PM
Recoverable
System.AggregateException: Project system data flow 'DataflowBlockSlim (ActionBlockSlimAsync`1 : 12811440)' closed because of an exception: System.AggregateException: One or more errors occurred. ---> System.ArgumentException: Must contain activeTargetFramework (.NETCoreApp,Version=v5.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()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.SemaphoreSlimExtensions.<ExecuteWithinLockAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.<<OnProjectFactoryCompletedAsync>g__OnActiveConfiguredProjectEvaluatedAsync|24_1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.<ProcessInputQueueAsync>d__5.MoveNext()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.ArgumentException: Must contain activeTargetFramework (.NETCoreApp,Version=v5.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()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.SemaphoreSlimExtensions.<ExecuteWithinLockAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.<<OnProjectFactoryCompletedAsync>g__OnActiveConfiguredProjectEvaluatedAsync|24_1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.<ProcessInputQueueAsync>d__5.MoveNext()<---
. ---> System.ArgumentException: Must contain activeTargetFramework (.NETCoreApp,Version=v5.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()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.SemaphoreSlimExtensions.<ExecuteWithinLockAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.<<OnProjectFactoryCompletedAsync>g__OnActiveConfiguredProjectEvaluatedAsync|24_1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.<ProcessInputQueueAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   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>g__action|0()
   at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.ArgumentException: Must contain activeTargetFramework (.NETCoreApp,Version=v5.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()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.SemaphoreSlimExtensions.<ExecuteWithinLockAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.<<OnProjectFactoryCompletedAsync>g__OnActiveConfiguredProjectEvaluatedAsync|24_1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.<ProcessInputQueueAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   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>g__action|0()
   at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )<---

===================

cc @ericstj @ViktorHofer @safern

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
drewnoakescommented, Jan 11, 2021

@ViktorHofer I’ve filed #6824 which disables the validation that’s firing here. Whilst the validation is sound in theory, it isn’t protecting against anything terribly serious and so I think the right thing to do is disable it for now. As I mentioned, in future I want to fix how we handle target frameworks in the dependencies tree, and at that time reinstate this validation.

1reaction
danmoseleycommented, Jan 1, 2021

This reproes simply cloning https://github.com/dotnet/runtime and opening src\libraries\System.Security.AccessControl\src\System.Security.AccessControl.csproj in 16.9 preview 3…

System.AggregateException: Project system data flow 'DataflowBlockSlim (ActionBlockSlimAsync`1 : 61111205)' closed because of an exception: System.AggregateException: One or more errors occurred. ---> System.ArgumentException: Value ".NETCoreApp,Version=v6.0" is unexpected. Must be a key in dependenciesByTargetFramework, which contains ".NETStandard,Version=v2.0,Profile=windows", ".NETCoreApp,Version=v2.1,Profile=Unix", ".NETCoreApp,Version=v2.1,Profile=windows", ".NETFramework,Version=v4.6.1,Profile=windows", ".NETStandard,Version=v2.0", ".NETStandard,Version=v2.0,Profile=Unix".
Parameter name: activeTargetFramework
   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()
Read more comments on GitHub >

github_iconTop Results From Across the Web

New projects not built when target platform is set explicitly
Close the project; Open the csproj file in notepad; replace all x86 with x64, save; Reopen the project and it works.
Read more >
How to: Modify the Target Framework and Platform Toolset ...
In Visual Studio, in Solution Explorer, select your project. On the menu bar, open the Project menu and choose Unload project. This command ......
Read more >
Configure projects to target platforms - Visual Studio
Learn how Visual Studio enables you to set up your applications to target different platforms, including the Arm64 platform.
Read more >
Troubleshoot .NET Framework targeting errors
To resolve the error, make sure that your application targets a .NET version that's compatible with the version that's targeted by the projects ......
Read more >
MSBuild Targets
Learn how MSBuild uses targets to group tasks together and allow the build process to be factored into smaller units.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found