0
votes

We have one project that includes both a Razor Class Library and a WASM project. Both are .NET 5.0.

We test and demo the RCL using the WASM project which is published regularly and works fine.

We have created a nuget package of the RCL some time ago and used that successfully in a Blazor server-side project.

Now I am trying to reference the RCL in a new WASM project (also .NET 5.0) and I'm strangely getting this error:

  <Target Name="_FailIfReferencingAspNetCoreApp" BeforeTargets="ResolveRuntimePackAssets">
    <Error
      Code="BLAZORSDK1001"
      Text="The project references the ASP.NET Core shared framework, which is not supported by Blazor WebAssembly apps. Remove the framework reference if directly referenced, or the package reference that adds the framework reference."
      Condition="'@(FrameworkReference->WithMetadataValue('Identity', 'Microsoft.AspNetCore.App')->Count())' != '0'" />
  </Target>

Is there something I'm missing? This is the .csproj of the RCL, which I guess is relevant:

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

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <PackageId>BlazorUI5</PackageId>
    <Version>1.0.39</Version>
    <Authors>CEO Dev Team</Authors>
    <Company>CEO Consultoría</Company>
    <PackageDescription>Blazor UI5 component package</PackageDescription>
    <RepositoryUrl>https://*******</RepositoryUrl>
    <AssemblyVersion>1.0.39.0</AssemblyVersion>
    <FileVersion>1.0.39.0</FileVersion>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
  </PropertyGroup>

  <ItemGroup>
    <Compile Remove="Helper\**" />
    <Content Remove="Helper\**" />
    <EmbeddedResource Remove="Helper\**" />
    <None Remove="Helper\**" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="5.0.3" />
  </ItemGroup>
  
  <ItemGroup>
    <SupportedPlatform Include="browser" />
  </ItemGroup>

</Project>

I find it strange that the reference works in the same solution, but it doesn't work using the package in another WASM solution, yet it does in another Blazor-server solution...

Any suggestions on what to check here?

Thanks,

Joerg

2
I have same problem rn. Did you find the solution for this?JkAlombro
It's currenty working yes, but I don't remember what I did to solve it. It may have been a bug of VS that fixed itself by closing and reloading all projects, but I honestly don't remember anymore.Joerg
For some reason, I was able to also solve this randomly as well. Maybe I'll post the answer here so others might solve it the same way I did.JkAlombro

2 Answers

0
votes

I think I have the same problem but slightly different situation. I have a Blazor WASM and I also created a RCL for my reusable components. I transferred all of my components to RCL and also downloaded Blazorise lib to that RCL then when I try reference it to my Blazor WASM, I got the same error like you did. I tried different online solution like restarting VS, deleting .vs folder, deleting bin folder, etc but nothing seems to work.

HOW I SOLVED IT

I created a new RCL and referenced it to my Blazor WASM app right away to see if it reacts the same but there's no error. I transferred my components one by one to see where the error will trigger but no error was found. Lastly, I installed Blazorise to my RCL and still no error. So basically I have a working RCL now that is basically the same one that got an error. The only difference was I referenced it first before transferring my components. I have no idea why the other one have an error but this solution might help others.

0
votes

I have the same problem too, it is a problem of microsoft doesn't send the right exception details, so you can publish your blazor wasm app using

dotnet publish -v detailed

so you will see the right exception