Kelvin Tee
Kelvin Tee

Reputation: 33

Blazor WASM Project Referencing Error (BLAZORSDK1001)

I have one Server project and now trying to convert it into Progressive Web Application. When I reference the API, Model, and UI projects to it then the following error comes out:

<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>

The following code is the .csproj of the project, is there something I'm missing?

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

    <PropertyGroup>
        <TargetFramework>net5.0</TargetFramework>
        <ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
    </PropertyGroup>

    <ItemGroup>
        <Content Remove="wwwroot\service-worker.js" />
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="Blazored.Toast" Version="3.1.2" />
        <PackageReference Include="BlazorInputFile" Version="0.2.0" />
        <PackageReference Include="DevExpress.Blazor" Version="20.1.7" />
        <PackageReference Include="Hangfire.AspNetCore" Version="1.7.11" />
        <PackageReference Include="Hangfire.Core" Version="1.7.11" />
        <PackageReference Include="Hangfire.SqlServer" Version="1.7.11" />
        <PackageReference Include="LiquidTechnologies.Blazor.ModalDialog" Version="0.9.7" />
        <PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.2.0-preview3.20168.3" />
        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.4" />
        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.4" PrivateAssets="all" />
        <PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.3" />
        <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.3" />
        <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.3" />
        <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="5.0.5" />
        <PackageReference Include="Microsoft.AspNetCore.SignalR.Client.Core" Version="5.0.5" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.3">
            <PrivateAssets>all</PrivateAssets>
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
        <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
        <PackageReference Include="QRCoder" Version="1.4.1" />
        <PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
        <PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
        <PackageReference Include="Serilog.Sinks.Elasticsearch" Version="8.0.1" />
        <PackageReference Include="Serilog.Sinks.MSSqlServer" Version="5.3.0" />
        <PackageReference Include="Tewr.Blazor.FileReader" Version="2.0.0.20200" />
    </ItemGroup>

    <ItemGroup>
        <ProjectReference Include="..\DataAccess\DataAccess.csproj" />
        <ProjectReference Include="..\UI\UI.csproj" />
        <ProjectReference Include="..\API\API.csproj" />
        <ProjectReference Include="..\Model\Model.csproj" />
    </ItemGroup>
</Project>

Are there any suggestions on solving this issue?

Upvotes: 3

Views: 1978

Answers (1)

Henk Holterman
Henk Holterman

Reputation: 273179

"I have one Server project" is a little unclear since we can only see <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">. I assume you want ot convert form a Blazor Server App to a WebAssembly app?

The project type is now WebAssembly but you are including, amongst others, <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" />

You can't access a database from a browser app directly. It's not supported and it wouldn't be safe (all clients would have access to the connection string).

This project needs to be split into a Client and a Server (API) part.

Your best course is to create a project (in a temp folder) from the full Blazor Wasm + Asp.Net Hosted + Individual Accounts template. It'll give you a complete reference for what goes where.

Upvotes: 1

Related Questions