6
votes

I use .NET Core 5.0.100-preview.7.20366.6 , Blazor webassembly, Microsoft Visual Studio Community 2019 Preview Version 16.7.0 Preview 6.0

enter image description here

file foo.csproj

<Project Sdk="Microsoft.NET.Sdk.Web">

    <PropertyGroup>
        <TargetFramework>net5.0</TargetFramework>
        <RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
        <UseBlazorWebAssembly>true</UseBlazorWebAssembly>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="DevExpress.Blazor" Version="20.1.5" />
        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0-preview.7.20365.19" />
        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.0-preview.7.20365.19" PrivateAssets="all" />
        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="5.0.0-preview.7.20365.19" />
        <PackageReference Include="System.Net.Http.Json" Version="5.0.0-preview.7.20364.11" />
    </ItemGroup>

</Project>

When press F5 to run debug:

Error

NETSDK1073: The FrameworkReference 'Microsoft.AspNetCore.App' was not recognized

enter image description here

How to fix it?

2
Can you run dotnet --version from the command line and let us know what is that version?Brian Parker
5.0.100-preview.7.20366.6Do Nhu Vy
I suspect DevExpress.Blazor compatibility with .net 5.0. I don't have access to it to checkBrian Parker

2 Answers

5
votes

For .NET Core 3.1 apps, adding <GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks> to the .csproj file will prevent this error:

<PropertyGroup>
  <TargetFramework>netcoreapp3.1</TargetFramework>
  <GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
</PropertyGroup>
2
votes

I just resolved the same issue with this process:

-Close the project

-Delete the bin and obj folders in the Blazor.Client project

-Reopen the project

-Open Nuget Console: Tools -> Nuget Package Manager -> Nuget Package Manager Console

-Enter dotnet restore in the command line

After that I hit F5 and the project compiled, and started