@@ -19,29 +19,17 @@ public WasiLibraryModeTests(ITestOutputHelper output, SharedBuildPerTestClassFix
19
19
{
20
20
}
21
21
22
- [ Fact ]
23
- public void ConsoleBuildLibraryMode ( )
22
+ [ Theory ]
23
+ [ InlineData ( "Microsoft.NET.Sdk" , false ) ]
24
+ [ InlineData ( "Microsoft.NET.Sdk.WebAssembly" , true ) ]
25
+ public void LibraryModeBuild ( string sdk , bool hasWasmAppBundle )
24
26
{
25
27
string config = "Release" ;
26
28
string id = $ "{ config } _{ GetRandomId ( ) } ";
27
29
string projectFile = CreateWasmTemplateProject ( id , "wasiconsole" ) ;
28
- string code =
29
- """
30
- using System;
31
- using System.Runtime.InteropServices;
32
- public unsafe class Test
33
- {
34
- [UnmanagedCallersOnly(EntryPoint = "MyCallback")]
35
- public static int MyCallback()
36
- {
37
- Console.WriteLine("WASM Library MyCallback is called");
38
- return 100;
39
- }
40
- }
41
- """ ;
42
- string csprojCode =
43
- """
44
- <Project Sdk="Microsoft.NET.Sdk.WebAssembly">
30
+ string csprojCode =
31
+ $ """
32
+ <Project Sdk="{ sdk } ">
45
33
<PropertyGroup>
46
34
<TargetFramework>net9.0</TargetFramework>
47
35
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
@@ -51,6 +39,7 @@ public static int MyCallback()
51
39
</PropertyGroup>
52
40
</Project>
53
41
""" ;
42
+ string code = File . ReadAllText ( Path . Combine ( BuildEnvironment . TestAssetsPath , "LibraryMode.cs" ) ) ;
54
43
File . WriteAllText ( Path . Combine ( _projectDir ! , "Program.cs" ) , code ) ;
55
44
File . WriteAllText ( Path . Combine ( _projectDir ! , $ "{ id } .csproj") , csprojCode ) ;
56
45
string projectName = Path . GetFileNameWithoutExtension ( projectFile ) ;
@@ -62,9 +51,8 @@ public static int MyCallback()
62
51
DotnetWasmFromRuntimePack : false ,
63
52
CreateProject : false ,
64
53
Publish : false ,
54
+ AssertAppBundle : hasWasmAppBundle ,
65
55
TargetFramework : BuildTestBase . DefaultTargetFramework
66
56
) ) ;
67
-
68
- Assert . Contains ( "Build succeeded." , output ) ;
69
57
}
70
58
}
0 commit comments