Skip to content

Commit 54df47e

Browse files
committed
new task ForceMSBuildGC
1 parent 1f7d01c commit 54df47e

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

eng/testing/tests.browser.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@
207207
</ItemGroup>
208208

209209
<WriteLinesToFile File="$(WasmMainHtmlPath)" Lines="&lt;html&gt;&lt;body&gt;&lt;script type='module' src='$(WasmMainJSFileName)'&gt;&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;" Overwrite="True" Condition="!Exists('$(WasmMainHtmlPath)')"/>
210+
211+
<ForceMSBuildGC />
210212
</Target>
211213

212214
<Target Name="_PrepareForAOTOnHelix">

eng/testing/tests.wasi.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@
129129
TargetPath="%(WasmFilesToIncludeFromPublishDir.Identity)"
130130
Condition="'%(WasmFilesToIncludeFromPublishDir.Identity)' != ''" />
131131
</ItemGroup>
132+
133+
<ForceMSBuildGC />
132134
</Target>
133135

134136
<Target Name="_PrepareForAOTOnHelix">

eng/testing/tests.wasm.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@
9393
TaskName="Microsoft.WebAssembly.Build.Tasks.GenerateAOTProps"
9494
AssemblyFile="$(WasmBuildTasksAssemblyPath)" TaskFactory="TaskHostFactory" />
9595

96+
<UsingTask TaskName="Microsoft.WebAssembly.Build.Tasks.ForceMSBuildGC" AssemblyFile="$(WasmBuildTasksAssemblyPath)" />
97+
9698
<Target Name="_BundleAOTTestWasmAppForHelix" DependsOnTargets="$(_BundleAOTTestWasmAppForHelixDependsOn)">
9799
<PropertyGroup>
98100
<_MainAssemblyPath Condition="'%(WasmAssembliesToBundle.FileName)' == $(AssemblyName) and '%(WasmAssembliesToBundle.Extension)' == '.dll'">%(WasmAssembliesToBundle.Identity)</_MainAssemblyPath>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 Microsoft.Build.Framework;
6+
using Microsoft.Build.Utilities;
7+
8+
namespace Microsoft.WebAssembly.Build.Tasks
9+
{
10+
public class ForceMSBuildGC : Task
11+
{
12+
public override bool Execute()
13+
{
14+
GC.Collect();
15+
GC.WaitForPendingFinalizers();
16+
return true;
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)