weikio/PluginFramework

Can't work in Blazor WebAssembly App

darrenji opened this issue · 1 comments

There is a Blazor Server sample, which is successful. Then I created a Blazor WebAssembly App and build the project. It shows:

Weikio.PluginFramework.Samples.Shared.csproj targets netcoreapp3.1. It can't be targeted to .NETStandard,Version=v2.1
Weikio.PluginFramework.AspNetCore.csproj targets netcoreapp3.1. It can't be targeted to .NETStandard,Version=v2.1

I noticed the TargetFramework in the Blazor WebAssembly App project is:

<PropertyGroup>
    <TargetFramework>netstardard2.1</TargetFramework>
</PropertyGroup>

How to solve this?

I solved this problem by using conditional compilation.

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

  <PropertyGroup>
    <TargetFrameworks>netstandard2.1;netcoreapp3.1</TargetFrameworks>
    <RazorLangVersion>3.0</RazorLangVersion>
  </PropertyGroup>


  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.1" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.1" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.1" PrivateAssets="all" />
    <PackageReference Include="System.Net.Http.Json" Version="3.2.0" />
  </ItemGroup>
  
  <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
    <ProjectReference Include="..\..\SourceCodes\PluginFramework\samples\Shared\Weikio.PluginFramework.Samples.Shared\Weikio.PluginFramework.Samples.Shared.csproj" />
    <ProjectReference Include="..\..\SourceCodes\PluginFramework\src\Weikio.PluginFramework.AspNetCore\Weikio.PluginFramework.AspNetCore.csproj" />
  </ItemGroup>

</Project>