JeremyLikness / MvpSummitTaskList

Example in MVP summit of using connected services and adding (persisted) SQLite to Blazor Wasm.
MIT License
25 stars 6 forks source link

Sqlite cannot be compiled #4

Open wz172 opened 2 years ago

wz172 commented 2 years ago

When I operate 【MvpSummitWasm】 Into the sqlite。

image

When I run the project, I get the following error.I know this is the webAssembly generation that is not included in SQLite.But I have followed the documentation to bring Nuget into the project

image

But I have a caveat when I build.

C:\Program Files\dotnet\sdk-manifests\6.0.300\microsoft.net.workload.mono.toolchain\WorkloadManifest.targets(105,7): warning : @(NativeFileReference) is not empty, but the native references won't be linked in, because neither $(WasmBuildNative), nor $(RunAOTCompilation) are 'true'. NativeFileReference=C:\Users\Administrator.nuget\packages\sqlitepclraw.lib.e_sqlite3\2.1.0-pre20220318192836\buildTransitive\net6.0....\runtimes\browser-wasm\nativeassets\net6.0\e_sqlite3.a

Do not see and video your operation [link in ECMM..

What should I do ...... Thank you very much

saborrie commented 1 year ago

I had the same error message. I couldn't figure it out until I tried adding <WasmBuildNative>true</WasmBuildNative> which gave me an error message that was more helpful - I had not installed the 'wasm-tools' workload.

I don't really know what "WasmBuildNative" does as I can't find any docs about it, but it seems to be needed for me.

I then ran dotnet workload install wasm-tools-net6 and dotnet workload install wasm-tools and now it is working just like in Jeremy's YouTube video. See the Wasm Tools docs for more details.

I ended up with this csproj:

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

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <WasmBuildNative>true</WasmBuildNative>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.3" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.3" PrivateAssets="all" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="7.0.0-preview.2.22153.1" />
    <PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.0-pre20220318192836" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\MvpSummit.Domain\MvpSummit.Domain.csproj" />
    <ProjectReference Include="..\MvpSummitUi\MvpSummitUi.csproj" />
  </ItemGroup>

</Project>