I Create a new" blazor webassembly" and new a "Razor Class Library" for components. but when I add"Razor Class Library" reference to "Blazor webassembly" project (no matter add a reference to which project -Server or Client even Shared)
after that give me errors:
Severity Code Description Project File Line Suppression State
Error CS0006 Metadata file 'C:\Users\Arman Es\source\repos\ASPNET5BlazorWasm\ASPNET5BlazorWasm\Client\bin\Debug\net5.0\ref\ASPNET5BlazorWasm.Client.dll' could not be found ASPNET5BlazorWasm.Server C:\Users\Arman Es\source\repos\ASPNET5BlazorWasm\ASPNET5BlazorWasm\Server\CSC 1 Active
and
Severity Code Description Project File Line Suppression State
Error NETSDK1082 There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'. ASPNET5BlazorWasm.Client C:\Program Files\dotnet\sdk\5.0.100-rc.2.20479.15\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets 387
also, give me a warning
Severity Code Description Project File Line Suppression State
Warning RAZORSDK1007 Reference assembly C:\Users\Arman Es\source\repos\ASPNET5BlazorWasm\ASPNET5BlazorWasm\Client\bin\Debug\net5.0\ASPNET5BlazorWasm.Client.dll could not be found. This is typically caused by build errors in referenced projects. ASPNET5BlazorWasm.Server C:\Program Files\dotnet\sdk\5.0.100-rc.2.20479.15\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.MvcApplicationPartsDiscovery.targets 54
But when I remove the "Razor Class Library" Reference from "Blazor Webassembly", errors and waning are fixed
razor class library .csproj file:
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<Compile Update="Components\SearchComponent.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>SearchComponent.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Components\SearchComponent.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>SearchComponent.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>
@djary thanks for contacting us.
The issue here is that you are referencing "Microsoft.AspNetCore.App" (Essentially all the ASP.NET Core server libraries) which is not supported on Blazor webassembly. You should remove the framework reference and reference the components SDK instead.
@javiercn Thanks for answering, can you tell me how can I reference to components SDK?
<PackageReference Include="Microsoft.AspNetCore.Components" Version="5.0.0-rc.2.20475.17" />
Nice, I Using <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0-rc.2.20475.17" /> instead of <PackageReference Include="Microsoft.AspNetCore.Components" Version="5.0.0-rc.2.20475.17" />. thank you
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.
See our Issue Management Policies for more information.