@@ -19,29 +19,17 @@ public WasiLibraryModeTests(ITestOutputHelper output, SharedBuildPerTestClassFix
1919 {
2020 }
2121
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 )
2426 {
2527 string config = "Release" ;
2628 string id = $ "{ config } _{ GetRandomId ( ) } ";
2729 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 } ">
4533 <PropertyGroup>
4634 <TargetFramework>net9.0</TargetFramework>
4735 <RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
@@ -51,6 +39,7 @@ public static int MyCallback()
5139 </PropertyGroup>
5240 </Project>
5341 """ ;
42+ string code = File . ReadAllText ( Path . Combine ( BuildEnvironment . TestAssetsPath , "LibraryMode.cs" ) ) ;
5443 File . WriteAllText ( Path . Combine ( _projectDir ! , "Program.cs" ) , code ) ;
5544 File . WriteAllText ( Path . Combine ( _projectDir ! , $ "{ id } .csproj") , csprojCode ) ;
5645 string projectName = Path . GetFileNameWithoutExtension ( projectFile ) ;
@@ -62,9 +51,8 @@ public static int MyCallback()
6251 DotnetWasmFromRuntimePack : false ,
6352 CreateProject : false ,
6453 Publish : false ,
54+ AssertAppBundle : hasWasmAppBundle ,
6555 TargetFramework : BuildTestBase . DefaultTargetFramework
6656 ) ) ;
67-
68- Assert . Contains ( "Build succeeded." , output ) ;
6957 }
7058}
0 commit comments