Skip to content

[net6.0][BlazorWasmSdk] build does not link native files #56783

@emepetres

Description

@emepetres

Blazor WASM SDK only links native libraries on dotnet publish, so it is not possible to debug the solution while using native linking. The reason is that emscripten targets seems to be only executed on publish.

I've been playing with WasmBuildAppAfterThisTarget property but no luck.

How could I link native files on dotnet build?

Sample csproj:

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

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <WasmBuildNative>true</WasmBuildNative>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.0-rc.1.21376.14" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.0-rc.1.21376.14" PrivateAssets="all" />
  </ItemGroup>

  <PropertyGroup>
    <UsingBrowserRuntimeWorkload>true</UsingBrowserRuntimeWorkload>
    <!-- <WasmBuildAppAfterThisTarget>Build</WasmBuildAppAfterThisTarget> -->
    <WasmBuildNative>true</WasmBuildNative>
  </PropertyGroup>

  <ItemGroup>
    <NativeFileReference Include="libTest.o" ScanForPInvokes="true" />
  </ItemGroup>

</Project> 

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions