C
C#ā€¢2y ago
Thinker

āœ… Error when including a project reference in a Blazor WASM project

I'm getting an error There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'. only when including a ProjectReference to another project in my solution in a Blazor WASM project. Both projects are targeting net7.0. Do I have to do something special to get the project reference to work properly with WASM or something?
12 Replies
phaseshift
phaseshiftā€¢2y ago
Did you miss an installer workload maybe? Complete guess...
Thinker
ThinkerOPā€¢2y ago
installer workload? The entire csproj is this
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.2" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Merpie.Common\Merpie.Common.csproj" />
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.2" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Merpie.Common\Merpie.Common.csproj" />
</ItemGroup>

</Project>
phaseshift
phaseshiftā€¢2y ago
Things you select in the installer
Thinker
ThinkerOPā€¢2y ago
What installer?
phaseshift
phaseshiftā€¢2y ago
Studio
Thinker
ThinkerOPā€¢2y ago
Visual Studio? Well, I'm primarily using Rider, but I'm getting that error even when using dotnet build
phaseshift
phaseshiftā€¢2y ago
It looks like a missing runtime
Thinker
ThinkerOPā€¢2y ago
Hmm, odd since it works when I don't have the project reference I have the Microsoft.AspNetCore.App 7.0.2 runtime installed, although perhaps I do need the WASM runtime?
phaseshift
phaseshiftā€¢2y ago
Asp project might just not be compatible with blazor runtime. There are some stack overflow threads on it. Didn't try to hard to understand šŸ˜…
Thinker
ThinkerOPā€¢2y ago
Well... I added <UseBlazorWebAssembly>true</UseBlazorWebAssembly> and changed the SDK to Microsoft.NET.Sdk.Web instead of Microsoft.NET.Sdk.BlazorWebAssembly now it builds ĀÆ\_(惄)_/ĀÆ Except now the website just gets stuck at loading with a warning that it failed to load _framework/blazor.webassembly.js So the issue is probably that the other project is not compatible with Blazor WASM, right? How would I make it compatible?
phaseshift
phaseshiftā€¢2y ago
šŸ¤·ā€ā™‚ļø my knowledge expired already. Have you gone through this? https://stackoverflow.com/questions/63993294/there-was-no-runtime-pack-for-microsoft-aspnetcore-app-available-for-the-specifi
Stack Overflow
There was no runtime pack for Microsoft.AspNetCore.App available fo...
Trying to migrate from ASP.NET Core 3.1 to 5.0 using this guide provided by Microsoft. Installed SDK 5.0.100-rc.1 with runtimes. Updated project as guide says and still getting following error: The...
Thinker
ThinkerOPā€¢2y ago
yes Problem solved, issue was that the project has a reference to Microsoft.AspNetCore.App which caused it to not work.

Did you find this page helpful?