Skip to content

Commit 54c40c8

Browse files
authored
Merge pull request #60 from jsturtevant/fix-publish-step
Fix so that compilation runs in correct order
2 parents 396ccb3 + 0c86722 commit 54c40c8

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ wasmtime composed.wasm
194194
While you can run wasm-tools manually, you can also generate this automatically. One way to do this is to [create a new project](./samples/calculator/CalculatorComposed/) and add the following:
195195

196196
```xml
197-
<Target Name="ComposeWasmComponent" AfterTargets="AfterBuild">
197+
<Target Name="ComposeWasmComponent" AfterTargets="Publish">
198198
<PropertyGroup>
199199
<EntrypointComponent>../CalculatorHost/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/calculatorhost.wasm</EntrypointComponent>
200200
<DependencyComponent>../Adder/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/adder.wasm</DependencyComponent>

samples/calculator/CalculatorComposed/CalculatorComposed.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM"/>
1717
</ItemGroup>
1818

19-
<Target Name="ComposeWasmComponent" AfterTargets="AfterBuild">
19+
<Target Name="ComposeWasmComponent" AfterTargets="Publish">
2020
<PropertyGroup>
2121
<EntrypointComponent>../CalculatorHost/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/CalculatorHost.wasm</EntrypointComponent>
2222
<DependencyComponent>../Adder/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/adder.wasm</DependencyComponent>
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
2-
<Target Name="EmitWasmOnBuild" AfterTargets="CopyFilesToOutputDirectory" DependsOnTargets="LinkNativeLlvm;"
3-
Condition="'$(RuntimeIdentifier)' == 'wasi-wasm'">
4-
<Message Importance="high" Text="Emit on build $(ProjectName) " />
5-
</Target>
2+
<!--
3+
This links the publish step with the build so that when a user runs `dotnet build` they get a wasm file.
4+
-->
5+
<Target Name="PublishAfterBuild" AfterTargets="Build" DependsOnTargets="Publish" Condition="'$(RuntimeIdentifier)' == 'wasi-wasm'" />
66
</Project>

test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</ItemGroup>
3030

3131
<!-- After build, create the composed component so it can be executed in the test -->
32-
<Target Name="ComposeWasmComponent" AfterTargets="AfterBuild">
32+
<Target Name="ComposeWasmComponent" AfterTargets="Publish">
3333
<PropertyGroup>
3434
<DependencyComponent>../E2EProducer/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/e2eproducer.wasm</DependencyComponent>
3535
</PropertyGroup>

test/WasmComponentSdkTest/WasmComponentSdkTest/SimpleProducerConsumerTest.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void CanComposeImportWithExport()
4949
[Fact]
5050
public void CanBuildAppFromOci()
5151
{
52-
var composed = FindModulePath("../testapps/OciWit", "ociwit.wasm");
52+
var composed = FindModulePath($"../testapps/OciWit/bin/{Config}", "ociwit.wasm");
5353
var stdout = ExecuteCommandComponent(composed);
5454
Assert.StartsWith("Oci is awesome!", stdout);
5555
}
@@ -89,11 +89,18 @@ private static string FindModulePath(string searchDir, string filename)
8989
}
9090

9191
var matches = Directory.GetFiles(resolvedSearchDir, filename, SearchOption.AllDirectories);
92-
if (matches.Count() != 1)
92+
if (matches.Count() == 1)
9393
{
94+
return Path.GetFullPath(matches.Single());
95+
}
96+
else if (matches.Count() == 2 && matches.Any(x => Path.GetFullPath(x).Contains($"wasi-wasm\\native"))) {
97+
return Path.GetFullPath(matches.First(x => Path.GetFullPath(x).Contains($"wasi-wasm\\native")));
98+
}
99+
else if (matches.Count() == 2 && matches.Any(x => Path.GetFullPath(x).Contains($"wasi-wasm/native"))) {
100+
return Path.GetFullPath(matches.First(x => Path.GetFullPath(x).Contains($"wasi-wasm/native")));
101+
}
102+
else {
94103
throw new Exception($"Failed to get modules path, matched {matches.Count()} entries for directory {resolvedSearchDir} and filename {filename}.");
95104
}
96-
97-
return Path.GetFullPath(matches.Single());
98105
}
99106
}

test/WasmComponentSdkTest/testapps/SimpleConsumer/SimpleConsumer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</ItemGroup>
2828

2929
<!-- After build, create the composed component so it can be executed in the test -->
30-
<Target Name="ComposeWasmComponent" AfterTargets="AfterBuild">
30+
<Target Name="ComposeWasmComponent" AfterTargets="Publish">
3131
<PropertyGroup>
3232
<DependencyComponent>../SimpleProducer/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/simpleproducer.wasm</DependencyComponent>
3333
</PropertyGroup>

0 commit comments

Comments
 (0)