When an ASP .Net Core web project has RID <RuntimeIdentifier>win7-x64</RuntimeIdentifier>, then project load shows the following error
_Project is targeting runtime 'win7-x64' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core._
and the above error is from "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.1.0\build\netcoreapp2.1\Microsoft.NETCore.App.targets"
I notice this error happening only on 16.8 Preview 4 build. (Version 16.8.0 Preview 4.0 [30509.233.main]) and the Dependencies tree shows some warning

Repro Steps:
@JunTaoLuo is this an ASPNet issue, should it be transferred to your repo?
I'm not sure it's an ASPNET issue. Specifically, the error that was encountered is
Project is targeting runtime 'win7-x64' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core.
However, I'm a little confused why it's trying to resolve the runtime assets from microsoft.netcore.app. The runtime assets are contained in the RID specific packages: https://www.nuget.org/packages/runtime.win-x64.Microsoft.NETCore.App/2.1.22. My suspicion here is that a restore is needed to be run after adding an explicit RID so that the appropriate reference to runtime.win-x64.Microsoft.NETCore.App is restored.
Okay, thanks for pointing that out. @wli3 do you think this looks like our issue or should it be moved somewhere else?
@sfoslund do you have time to look into it? It just happens for VS 16.8 Preview 4 sounds serious. For us looking into it should be most efficient.
I'm able to repro but I haven't been able to get anywhere with investigation because the build is succeeding. I'm not sure where this error is coming from or how Microsoft.NETCore.App.targets is getting run. @wli3 do you have any pointers?
@sfoslund so the commandline build works but it shows the error in VS? You could get a binlog with https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProjectSystemTools follow https://github.com/microsoft/microsoft-ui-xaml/blob/master/docs/debugging_buildfailures.md#collecting-binlogs-through-visual-studio
Both the command line and VS builds worked (verified with a binlog using the project system extension) but the error is still being surfaced to the user. @drewnoakes this looks like it might be a project system issue.
The dependencies tree is the last line of defence for a range of bugs. When everything was a warning icon like this, it usually indicates that the design-time build is failing. This is consistent with the regular and command line builds passing, as different targets are invoked by VS. You can use ProjectSystemTools to get a binlog of such builds and investigate.
EDIT @sfoslund I re-read your comment. Did you look at the DTB binlog?
@dsplaisted fixed a bug this week that could have caused this.
Also from Drew: take a look at the output of the resolved package reference task. If it's not returning anything, things will show triangles.
This looks like a dupe of https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1193477 which was closed as fixed in 16.8p4 with 5.0rc1.
@ravipal what version of the SDK do you have installed?
We still see that we RC2 SDK. We are trying to get a val build and see if it still repros
@drewnoakes I'm still seeing this repro with the val build from https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_git/VS/pullrequest/276296
@drewnoakes Here is my dotnet info
C:Usersravipal>dotnet --info
.NET SDK (reflecting any global.json):
Version: 5.0.100-rc.1.20452.10
Commit: 473d1b592e
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:Program Filesdotnetsdk5.0.100-rc.1.20452.10
Host (useful for support):
Version: 5.0.0-rc.1.20451.14
Commit: 38017c3935
.NET SDKs installed:
2.1.700 [C:Program Filesdotnetsdk]
5.0.100-preview.3.20211.8 [C:Program Filesdotnetsdk]
5.0.100-rc.1.20452.10 [C:Program Filesdotnetsdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.11 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.21 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.11 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.21 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.7 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0-preview.3.20210.6 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0-rc.1.20451.17 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.11 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.21 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 3.1.7 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 5.0.0-preview.3.20209.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 5.0.0-rc.1.20451.14 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.7 [C:Program FilesdotnetsharedMicrosoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.0-preview.3.20209.3 [C:Program FilesdotnetsharedMicrosoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.0-rc.1.20452.2 [C:Program FilesdotnetsharedMicrosoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
C:Usersravipal>
Ping @drewnoakes, have you been able to take a look at this?
Looks like this doesn't repro with the latest val build from https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/277292, closing now.
The 16.8 Preview 4 RC build still has this issue. @sfoslund Can you please keep this bug open?
Any update on this issue?
@drewnoakes have you been able to look at this?
@sfoslund I see two tasks failing in different design-time builds with the same error message:
ResolvePackageAssets calls a task of the same name in the SDK which logs this error.EnsureNETCoreAppRuntime explicitly emits this Error on condition Condition="'@(_ridSpecificNetCoreAppPackageDependencies)' == ''".I don't believe the Project System is involved here, and the Dependencies Tree is just showing a bug that's within the SDK. I don't have enough context on how runtime targeting works in the SDK to comment on why this may be.
@drewnoakes were you able to get a binlog on this? I think the reason we originally thought it was a project system issue was that the error was showing up in VS but binlogs were showing that the build was succeeding.
@sfoslund I saw the failures in design time builds only. You can get binlogs of those using the Project System Tools extension.
Yes, I used the project system tools extension to get the binlog I was looking at and it said that everything was succeeding (see this comment). That was several weeks ago now so it's possible the behavior has changed since then, have you been able to see failures in the binlogs?
Version 16.9.0 Preview 2.0 [30618.5.main]
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
</ItemGroup>
</Project>
Modify whitespace in the project to trigger a build if needed.

There's a .binlog at \\mlangfs1\public\drnoakes\dotnet-sdk-issue-13513
Thanks for providing the binlog @drewnoakes!
The error is coming from the EnsureNETCoreAppRuntime target and it doesn't look like this is owned by the SDK. @wli3 do you recognize this target or know who might own it?
I find this. Looks like it is removed https://github.com/dotnet/runtime/issues/3011
It was removed quite a while ago, I wonder why it's causing a failure now. (cc @ericstj @eerhardt as it looks like you were involved in the original removal)
It was removed quite a while ago
Note that the above repro is for a netcoreapp2.1 project. This target still exists in 2.1, but was removed in later versions.
I can repro this on the command line with:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
</ItemGroup>
</Project>
โฏ dotnet --version
5.0.100-rc.2.20479.15
โฏ dotnet build /t:ResolvePackageDependenciesDesignTime /bl
Microsoft (R) Build Engine version 16.8.0-preview-20475-05+aed5e7ed0 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Program Files\dotnet\sdk\5.0.100-rc.2.20479.15\MSBuild.dll -consoleloggerparameters:Summary -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\5.0.100-rc.2.20479.15\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\5.0.100-rc.2.20479.15\dotnet.dll -maxcpucount -restore -verbosity:m /bl /t:ResolvePackageDependenciesDesignTime .\WebApplication17.csproj
Determining projects to restore...
All projects are up-to-date for restore.
C:\Users\eerhardt\.nuget\packages\microsoft.netcore.app\2.1.17\build\netcoreapp2.1\Microsoft.NETCore.App.targets(19,5): error : Project is targeting runtime 'win7-x64' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. [C:\Users\eerhardt\source\repos\WebApplication17\WebApplication17\WebApplication17.csproj]
Build FAILED.
C:\Users\eerhardt\.nuget\packages\microsoft.netcore.app\2.1.17\build\netcoreapp2.1\Microsoft.NETCore.App.targets(19,5): error : Project is targeting runtime 'win7-x64' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core. [C:\Users\eerhardt\source\repos\WebApplication17\WebApplication17\WebApplication17.csproj]
0 Warning(s)
1 Error(s)
I assume we didn't change anything about the 2.1 version of Microsoft.NETCore.App package. So this break is probably something in the SDK. Looking around at that target:
<ItemGroup>
<_netCoreAppPackageDependencies
Include="@(PackageDependencies->WithMetadataValue('ParentPackage', '$(MSBuildThisFileName)/$(_Microsoft_NETCore_App_Version)'))" />
<_activeRIDNetCoreAppPackageDependencies
Include="@(_netCoreAppPackageDependencies->WithMetadataValue('ParentTarget', '$(NuGetTargetMoniker)/$(RuntimeIdentifier)'))" />
<_activeTFMNetCoreAppPackageDependencies
Include="@(_netCoreAppPackageDependencies->WithMetadataValue('ParentTarget', '$(NuGetTargetMoniker)'))" />
<_ridSpecificNetCoreAppPackageDependencies
Include="@(_activeRIDNetCoreAppPackageDependencies)"
Exclude="@(_activeTFMNetCoreAppPackageDependencies)" />
</ItemGroup>
<Error Condition="'@(_ridSpecificNetCoreAppPackageDependencies)' == ''"
Text="Project is targeting runtime '$(RuntimeIdentifier)' but did not resolve any runtime-specific packages for the '$(MSBuildThisFileName)' package. This runtime may not be supported by .NET Core." />
</Target>
The error is coming form "'@(_ridSpecificNetCoreAppPackageDependencies)' == ''", which should be populated above. Looking at the binlog, I _think_ the issue is this line:
<_activeRIDNetCoreAppPackageDependencies
Include="@(_netCoreAppPackageDependencies->WithMetadataValue('ParentTarget', '$(NuGetTargetMoniker)/$(RuntimeIdentifier)'))" />
When I look at the _netCoreAppPackageDependencies items I see:

Note the first value is netcoreapp2.1. But when I see what $(NuGetTargetMoniker) evaluates to, I see it is NuGetTargetMoniker = .NETCoreApp,Version=v2.1, which does not match netcoreapp2.1 in the Include condition above.
Did something about $(NuGetTargetMoniker) recently change?
EDIT: Looks like that change happened in https://github.com/dotnet/sdk/commit/715f9a6e882bb5a240b1be7266a9d09858ea6478#diff-91b6e543d33631c6d19a78b20c9832f0ff860cc8836cb7f522a7936508e525ad. cc @dsplaisted
Yes, we changed the ParentTarget values to use the TargetFramework instead of the TargetFrameworkMoniker. #13093
Unfortunately the target that is failing is coming from the 2.1 NuGet packages which we can't update. Could we override it with a dummy target in the .NET SDK? @eerhardt
The EnsureNETCoreAppRuntime target from the NuGet package doesn't even run during normal builds anymore, because the RunResolvePackageDependencies target it's scheduled after doesn't normally run anymore. It only happens to run in design-time builds because they still use RunResolvePackageDependencies.
Until we fix this issue, is there any workaround?
A workaround would be to put the following in a Directory.Build.targets file:
<Target Name="EnsureNETCoreAppRuntime" />
Thanks for the workaround. This issue is a blocker for 16.8 release. Can someone please add a Label or something to indicate that this is a blocker?
Also any ETA on the fix?
I don't believe this is a blocker for 16.8. It only impacts projects targeting .NET Core 2.x (and maybe 1.x) that have a RuntimeIdentifier specified in the project. Additionally, it doesn't stop the project from building, it just shows an error in the error list in VS and warnings in the solution explorer.
It is a blocker for Service Fabric applications where we specify the RuntimeIndentifier in the project file. When the Service Fabric users are upgraded to 16.8, they will start seeing this error and they may not aware that this is just design time build validation and can be ignored.
I also encountered this build error in VS 16.8.2 with a ASP.NET web app targeting netcoreapp2.2 and RuntimeIdentifier win-x64. Based on the suggestion of @dsplaisted, I workaround this issue by adding the following line to a PropertyGroup within my .csproj files
<EnsureNETCoreAppRuntime>false</EnsureNETCoreAppRuntime>
I'm seeing this issue since upgrading to VS 16.8.2 for all projects on netcoreapp3.1.
Currently not seeing any runtime issues; workaround provided above does hide the error - I would like to remove <EnsureNETCoreAppRuntime>false</EnsureNETCoreAppRuntime> sooner rather than later
I'm getting the same issue in VS 16.8.2 for netcoreapp2.1 targeting win-x64.

The solution <EnsureNETCoreAppRuntime>false</EnsureNETCoreAppRuntime> fixed my issue.
Do you need a binlog?
My machines dotnet --info:
.NET SDK (reflecting any global.json):
Version: 5.0.100
Commit: 5044b93829Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:Program Filesdotnetsdk5.0.100Host (useful for support):
Version: 5.0.0
Commit: cf258a14b7.NET SDKs installed:
1.1.14 [C:Program Filesdotnetsdk]
2.1.202 [C:Program Filesdotnetsdk]
2.1.509 [C:Program Filesdotnetsdk]
2.1.511 [C:Program Filesdotnetsdk]
2.1.513 [C:Program Filesdotnetsdk]
2.1.514 [C:Program Filesdotnetsdk]
2.1.515 [C:Program Filesdotnetsdk]
2.2.207 [C:Program Filesdotnetsdk]
5.0.100 [C:Program Filesdotnetsdk].NET runtimes installed:
Microsoft.AspNetCore.All 2.1.13 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.15 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.16 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.17 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.18 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.19 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.23 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.8 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.13 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.15 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.16 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.17 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.18 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.19 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.23 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.8 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.9 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.16 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 1.1.13 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.0.9 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.13 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.15 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.16 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.17 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.18 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.19 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.23 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.2.8 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 3.1.9 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 5.0.0 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0 [C:Program FilesdotnetsharedMicrosoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.9 [C:Program FilesdotnetsharedMicrosoft.WindowsDesktop.App]
This will be fixed in .NET SDK 5.0.101, which I believe will go out together with VS 16.8.3. So no need for a binlog or anything at this point.
Most helpful comment
This will be fixed in .NET SDK 5.0.101, which I believe will go out together with VS 16.8.3. So no need for a binlog or anything at this point.