C
C#16mo ago
frosty7350

❔ ✅ Native dependencies from razor class library to a wasm app project.

Hi! If I have a razor class library that has native dependencies. How do I pass the native dependencies to a wasm application? Currently I just have the .c files, define emscripten linker options and native dependencies on the application project to go around this so it -works- but it is not how I would like it to be.
3 Replies
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
frosty7350
frosty735016mo ago
So if a have a blazor wasm application and I use native dependencies like so https://learn.microsoft.com/en-us/aspnet/core/blazor/webassembly-native-dependencies?view=aspnetcore-7.0. The wasm build tools builds my .c files for wasm and I can use it with blazor components as expected. However, if I want to move my razor components that use the native dependencies to a separate class library I currently still need to keep the .c file in the blazor wasm application project. So basically my issue is that I need to define the native file reference and keep the .c file in the client application itself.
<PropertyGroup>
<EmccLinkOptimizationFlag>-s USE_WEBGL2=1 -s MAX_WEBGL_VERSION=3</EmccLinkOptimizationFlag>
</PropertyGroup>
<ItemGroup>
<NativeFileReference Include="WebGL2.c" />
</ItemGroup>
<PropertyGroup>
<EmccLinkOptimizationFlag>-s USE_WEBGL2=1 -s MAX_WEBGL_VERSION=3</EmccLinkOptimizationFlag>
</PropertyGroup>
<ItemGroup>
<NativeFileReference Include="WebGL2.c" />
</ItemGroup>
So how could I avoid needing to define the above + having the .c file inside the application project itself when using the class library? Do I need to create a nuget to include the class library in the simplest way possible in other projects?
ASP.NET Core Blazor WebAssembly native dependencies
Learn how to build Blazor WebAssembly apps with native dependencies built to run on WebAssembly in the browser.
Accord
Accord16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.