File tree Expand file tree Collapse file tree 7 files changed +826
-4
lines changed Expand file tree Collapse file tree 7 files changed +826
-4
lines changed Original file line number Diff line number Diff line change 15
15
16
16
<PropertyGroup >
17
17
<OutputPath >bin</OutputPath >
18
+ <_ScriptExt Condition =" '$(OS)' == 'Windows_NT'" >.cmd</_ScriptExt >
19
+ <_ScriptExt Condition =" '$(OS)' != 'Windows_NT'" >.sh</_ScriptExt >
20
+ <_Dotnet >$(RepoRoot)dotnet$(_ScriptExt)</_Dotnet >
21
+ <_ExeExt Condition =" $([MSBuild]::IsOSPlatform('WINDOWS'))" >.exe</_ExeExt >
22
+ <_Nodejs >$(RepoRoot)node$(_ScriptExt)</_Nodejs >
23
+ <_Npm >$(RepoRoot)npm$(_ScriptExt)</_Npm >
18
24
</PropertyGroup >
19
25
<PropertyGroup Condition =" '$(Configuration)' == 'Debug'" >
20
26
<WasiNativeStrip >false</WasiNativeStrip >
Original file line number Diff line number Diff line change 8
8
<_SampleProjectName >$([System.String]::Copy('$(_SampleProject)').Replace('.csproj',''))</_SampleProjectName >
9
9
<_MONO_LOG_LEVEL Condition =" false" >--env MONO_LOG_LEVEL=debug --env MONO_LOG_MASK=all</_MONO_LOG_LEVEL >
10
10
<_DOTNET_WASI_PRINT_EXIT_CODE >--env DOTNET_WASI_PRINT_EXIT_CODE=1</_DOTNET_WASI_PRINT_EXIT_CODE >
11
- <_ExeExt Condition =" $([MSBuild]::IsOSPlatform('WINDOWS'))" >.exe</_ExeExt >
12
11
</PropertyGroup >
13
12
14
13
<Target Name =" BuildSampleInTree"
22
21
bin/$(Configuration)/AppBundle/dotnet.native.wasm;
23
22
" >
24
23
<PropertyGroup >
25
- <_ScriptExt Condition =" '$(OS)' == 'Windows_NT'" >.cmd</_ScriptExt >
26
- <_ScriptExt Condition =" '$(OS)' != 'Windows_NT'" >.sh</_ScriptExt >
27
- <_Dotnet >$(RepoRoot)dotnet$(_ScriptExt)</_Dotnet >
28
24
<_AOTFlag Condition =" '$(RunAOTCompilation)' != ''" >/p:RunAOTCompilation=$(RunAOTCompilation)</_AOTFlag >
29
25
</PropertyGroup >
30
26
<Exec Command =" $(_Dotnet) publish -bl:publish.binlog /p:Configuration=$(Configuration) /p:TargetArchitecture=wasm /p:TargetOS=wasi $(_AOTFlag) $(_SampleProject)" />
55
51
IgnoreExitCode =" true" />
56
52
</Target >
57
53
54
+ <Target Name =" TranspileJCO"
55
+ Inputs ="
56
+ Program.cs;
57
+ $(_SampleProject);
58
+ $(MSBuildProjectFile);
59
+ $(TargetFileName);
60
+ bin/$(Configuration)/AppBundle/dotnet.native.wasm;
61
+ "
62
+ Outputs ="
63
+ bin/$(Configuration)/JCOBundle/dotnet.native.wasm;
64
+ " >
65
+ <Exec Command =" npm run transpile"
66
+ WorkingDirectory =" $(MSBuildProjectDirectory)" />
67
+ </Target >
68
+
69
+
70
+ <Target Name =" RunSampleWithNodeJS" DependsOnTargets =" BuildSampleInTree;TranspileJCO" >
71
+ <Exec Command =" npm run run"
72
+ WorkingDirectory =" $(MSBuildProjectDirectory)" />
73
+ </Target >
74
+
58
75
<Import Project =" $(RepositoryEngineeringDir)testing\wasi-provisioning.targets" />
59
76
</Project >
Original file line number Diff line number Diff line change
1
+ // Licensed to the .NET Foundation under one or more agreements.
2
+ // The .NET Foundation licenses this file to you under the MIT license.
3
+
4
+ using System ;
5
+ using System . Net . Http . Headers ;
6
+ using System . Net . Http ;
7
+ using System . Threading . Tasks ;
8
+ using System . Threading ;
9
+ using System . Runtime . CompilerServices ;
10
+
11
+ // keep in sync with src\mono\wasi\testassets\Http.cs
12
+ public static class WasiMainWrapper
13
+ {
14
+ public static async Task < int > MainAsync ( string [ ] args )
15
+ {
16
+ await Task . Delay ( 100 ) ;
17
+
18
+ using HttpClient client = new ( ) ;
19
+ client . DefaultRequestHeaders . Accept . Clear ( ) ;
20
+ client . DefaultRequestHeaders . Add ( "User-Agent" , "dotnet WASI unit test" ) ;
21
+
22
+ var query = "https://corefx-net-http11.azurewebsites.net/Echo.ashx" ;
23
+ var json = await client . GetStringAsync ( query ) ;
24
+
25
+ Console . WriteLine ( ) ;
26
+ Console . WriteLine ( "GET " + query ) ;
27
+ Console . WriteLine ( ) ;
28
+ Console . WriteLine ( json ) ;
29
+
30
+ return 0 ;
31
+ }
32
+
33
+ public static int Main ( string [ ] args )
34
+ {
35
+ return PollWasiEventLoopUntilResolved ( ( Thread ) null ! , MainAsync ( args ) ) ;
36
+
37
+ [ UnsafeAccessor ( UnsafeAccessorKind . StaticMethod , Name = "PollWasiEventLoopUntilResolved" ) ]
38
+ static extern int PollWasiEventLoopUntilResolved ( Thread t , Task < int > mainTask ) ;
39
+ }
40
+
41
+ }
Original file line number Diff line number Diff line change
1
+ <Project Sdk =" Microsoft.NET.Sdk" >
2
+ <PropertyGroup >
3
+ <TargetFramework >$(NetCoreAppCurrent)</TargetFramework >
4
+ <_WasiNeedsHttp >true</_WasiNeedsHttp >
5
+ <WasmSingleFileBundle >true</WasmSingleFileBundle >
6
+ <InvariantGlobalization >true</InvariantGlobalization >
7
+ </PropertyGroup >
8
+
9
+ <Target Name =" RunSample" DependsOnTargets =" RunSampleWithNodeJS" />
10
+ </Project >
Original file line number Diff line number Diff line change
1
+ import { run } from './Wasi.Jco.Http.Sample.js' ;
2
+
3
+ run . run ( ) ;
You can’t perform that action at this time.
0 commit comments