Error when running Blazor app before running any other .NET Core 3.0 app: Unable to generate deps.json, it may have been already generated
See original GitHub issueIf you create a Blazor app after installing the .NET Core 3.0 Preview 2 SDK and you have a clean NuGet package cache you get an error when running the app: “Unable to generate deps.json, it may have been already generated”.
Blazor apps rely on a DotNetCliToolReference
to run, but they also target .NET Standard:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RunCommand>dotnet</RunCommand>
<RunArguments>blazor serve</RunArguments>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="0.8.0-preview-19104-04" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.8.0-preview-19104-04" PrivateAssets="all" />
<DotNetCliToolReference Include="Microsoft.AspNetCore.Blazor.Cli" Version="0.8.0-preview-19104-04" />
</ItemGroup>
</Project>
It appears that the problem is that the Microsoft.NetCore.App package doesn’t get restored, which then causes the Blazor app to fail at runtime. If you create any other .NET Core app before trying to run the Blazor app, the Microsoft.NetCore.App package is then already restored and the app runs fine. At the very least the error message doesn’t really help you understand what is going on here.
Repro steps:
- Install .NET Core 3.0 Preview 2
dotnet new -i Microsoft.AspNetCore.Blazor.Templates::0.8.0-preview-19104-04
dotnet nuget locals all -c
dotnet new blazor -o BlazorApp1
cd BlazorApp1
dotnet run
Expected result:
- Blazor app runs successfully
Actual result:
- Unable to generate deps.json, it may have been already generated. You can specify the “-d” option before the tool name for diagnostic output (for example, “dotnet -d <toolname>”: C:\Program Files\dotnet\sdk\3.0.100-preview-010184\Sdks\Microsoft.NET.Sdk\targets\GenerateDeps\GenerateDeps.proj
To workaround the issue you can create any .NET Core app, which will result in the missing Microsoft.AspNetCore.App package to get successfully restored.
Workaround:
cd ..
dotnet new console -o ConsoleApp1
cd BlazorApp1
dotnet run
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:10 (4 by maintainers)
This worked for me. Thank you.
Closing as fixed.