Skip to content

[wasm] Compilation with WasmBuildNative fails with dependency containing hyphen in the name #78992

Closed
@stanoddly

Description

@stanoddly

Description

Compilation of wasm based project fails with a nuget package dependency containing hyphen in the name.

Reproduction Steps

Prepare the project:

mkdir WasmTest
cd WasmTest
dotnet new wasmbrowser

Add nuget package which contains a hyphen in the name

dotnet add package Raylib-cs

Add <WasmBuildNative>true</WasmBuildNative> to WasmTest.csproj inside PropertyGroup

  <PropertyGroup>
    ...
    <WasmBuildNative>true</WasmBuildNative>
  </PropertyGroup>

run:

dotnet build

Expected behavior

Successful compilation.

Actual behavior

The compilation of generated C files fails because invalid function identifier is generated:

void wasm_native_to_interp_Raylib-cs_Logging_LogConsole  (int arg0,int arg1,int arg2) { 
                                ^^^

Truncated compilation log:

C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\7.0.0\Sdk\WasmApp.Native.targets(328,5): error : D:\Users\stan\Projects\WasmTest\obj\Debug\net7.0\browser-wasm\wasm\for-build\pinvoke-table.h:282:6: error: variable has incomplete type 'void' [D:\Users\stan\Projects\WasmTest\WasmTest.csproj]
C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\7.0.0\Sdk\WasmApp.Native.targets(328,5): error : void wasm_native_to_interp_Raylib-cs_Logging_LogConsole (int arg0,int arg1,int arg2) {  [D:\Users\stan\Projects\WasmTest\WasmTest.csproj]
C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\7.0.0\Sdk\WasmApp.Native.targets(328,5): error :      ^ [D:\Users\stan\Projects\WasmTest\WasmTest.csproj]
C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\7.0.0\Sdk\WasmApp.Native.targets(328,5): error : D:\Users\stan\Projects\WasmTest\obj\Debug\net7.0\browser-wasm\wasm\for-build\pinvoke-table.h:282:34: error: expected ';' after top level declarator [D:\Users\stan\Projects\WasmTest\WasmTest.csproj]

The rest of the log is just a noise, I believe this the most important part.

Regression?

No response

Known Workarounds

No response

Configuration

.NET SDK 7.0.100, Windows 10 x64
I assume I use the latest wasm-tools (is there a way to find the version)

Other information

I guess the problem is on this very line:

string module_symbol = method.DeclaringType!.Module!.Assembly!.GetName()!.Name!.Replace(".", "_");

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions