diff --git a/eng/Versions.props b/eng/Versions.props
index e84fd7460a349c..5928e66092d324 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -164,7 +164,7 @@
2.0.4
4.12.0
2.14.3
- 6.0.100-rc.2.21463.12
+ 6.0.100-rc.2.21467.10
6.0.0-preview-20210916.1
diff --git a/src/mono/wasm/BlazorOverwrite.targets b/src/mono/wasm/BlazorOverwrite.targets
index a276d385723725..bc51baa0d0c236 100644
--- a/src/mono/wasm/BlazorOverwrite.targets
+++ b/src/mono/wasm/BlazorOverwrite.targets
@@ -73,11 +73,6 @@ Copyright (c) .NET Foundation. All rights reserved.
true
false
ComputeFilesToPublish;_GatherWasmFilesToPublish;$(WasmNestedPublishAppDependsOn)
- <_ScrambleDotnetJsFileNameAfterThisTarget Condition="'$(UsingBrowserRuntimeWorkload)' != 'true'">ResolveRuntimePackAssets
- <_ScrambleDotnetJsFileNameAfterThisTarget Condition="'$(UsingBrowserRuntimeWorkload)' == 'true'">WasmBuildApp
-
-
- Publish
@@ -114,121 +109,13 @@ Copyright (c) .NET Foundation. All rights reserved.
-
-
-
- <_DotNetJsVersion>$(BundledNETCoreAppPackageVersion)
- <_DotNetJsVersion Condition="'$(RuntimeFrameworkVersion)' != ''">$(RuntimeFrameworkVersion)
- <_BlazorDotnetJsFileName>dotnet.$(_DotNetJsVersion).js
-
-
-
- <_DotNetJsItem Remove="@(_DotNetJsItem)" />
- <_DotNetJsItem Include="@(WasmNativeAsset)" Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.js'">
- _framework/$(_BlazorDotnetJsFileName)
- native
- true
-
-
-
-
- <_DotnetJsStaticWebAssetCandidate Remove="@(_DotnetJsStaticWebAssetCandidate)" />
- <_DotnetJsCopyCandidates Remove="@(_DotnetJsCopyCandidates)" />
-
-
-
-
-
-
-
-
-
-
-
- <_DotnetJsStaticWebAsset Include="@(_DotnetJsStaticWebAssetCandidate->'%(ContentRoot)_framework\dotnet.js')" />
- <_BlazorStaticWebAsset Include="@(_DotnetJsStaticWebAsset)" />
-
-
-
-
-
-
- <_DotNetJsVersion>$(BundledNETCoreAppPackageVersion)
- <_DotNetJsVersion Condition="'$(RuntimeFrameworkVersion)' != ''">$(RuntimeFrameworkVersion)
- <_BlazorDotnetJsFileName>dotnet.$(_DotNetJsVersion).js
-
-
-
- <_DotNetJsItem Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.DestinationSubPath)' == 'dotnet.js' AND '%(ReferenceCopyLocalPaths.AssetType)' == 'native'">
- _framework/$(_BlazorDotnetJsFileName)
-
-
-
-
- <_DotNetJsItem Remove="@(_DotNetJsItem)" />
- <_DotNetJsItem Include="@(WasmNativeAsset)" Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.js'">
- _framework/$(_BlazorDotnetJsFileName)
- native
- true
-
-
-
-
-
-
-
-
-
-
-
-
- <_DotnetJsStaticWebAsset Include="@(_DotnetJsStaticWebAssetCandidate->'%(ContentRoot)_framework\dotnet.js')" />
- <_BlazorStaticWebAsset Include="@(_DotnetJsStaticWebAsset)" />
-
-
-
-
+
+
@@ -265,6 +152,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<_BlazorConfigFileCandidates Include="@(StaticWebAsset)" Condition="'%(SourceType)' == 'Discovered'" />
+
@@ -278,6 +166,7 @@ Copyright (c) .NET Foundation. All rights reserved.
TimeZoneSupport="$(_BlazorEnableTimeZoneSupport)"
InvariantGlobalization="$(_BlazorInvariantGlobalization)"
CopySymbols="$(_BlazorCopyOutputSymbolsToOutputDirectory)"
+ BundledNETCoreAppPackageVersion="$(BundledNETCoreAppPackageVersion)"
OutputPath="$(OutputPath)"
>
@@ -490,6 +379,7 @@ Copyright (c) .NET Foundation. All rights reserved.
+
<_BlazorAotEnabled>$(UsingBrowserRuntimeWorkload)
@@ -519,6 +409,7 @@ Copyright (c) .NET Foundation. All rights reserved.
InvariantGlobalization="$(_BlazorInvariantGlobalization)"
CopySymbols="$(CopyOutputSymbolsToPublishDirectory)"
ExistingAssets="@(_BlazorPublishPrefilteredAssets)"
+ BundledNETCoreAppPackageVersion="$(BundledNETCoreAppPackageVersion)"
>
@@ -649,7 +540,7 @@ Copyright (c) .NET Foundation. All rights reserved.
diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs
index 687429a3fca482..f4c666687c11c8 100644
--- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs
+++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs
@@ -4,6 +4,7 @@
using System;
using System.IO;
using System.Linq;
+using System.Text.RegularExpressions;
using Xunit;
using Xunit.Abstractions;
@@ -171,6 +172,57 @@ public void WithNativeReference_AOTOnCommandLine(string config)
BlazorPublish(id, config, expectedFileType: NativeFilesType.Relinked);
}
+ [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))]
+ [InlineData("Debug")]
+ [InlineData("Release")]
+ public void WithDllImportInMainAssembly(string config)
+ {
+ // Based on https://github.com/dotnet/runtime/issues/59255
+ string id = $"blz_dllimp_{config}";
+ string projectFile = CreateProjectWithNativeReference(id);
+ string nativeSource = @"
+#include
+
+extern ""C"" {
+ int cpp_add(int a, int b) {
+ return a + b;
+ }
+}";
+ File.WriteAllText(Path.Combine(_projectDir!, "mylib.cpp"), nativeSource);
+
+ string myDllImportCs = @$"
+ using System.Runtime.InteropServices;
+namespace {id};
+
+public static class MyDllImports
+{{
+ [DllImport(""mylib"")]
+ public static extern int cpp_add(int a, int b);
+}}";
+ File.WriteAllText(Path.Combine(_projectDir!, "Pages", "MyDllImport.cs"), myDllImportCs);
+
+ AddItemsPropertiesToProject(projectFile, extraItems: @"");
+
+ BlazorBuild(id, config, expectedFileType: NativeFilesType.Relinked);
+ CheckNativeFileLinked(forPublish: false);
+
+ BlazorPublish(id, config, expectedFileType: NativeFilesType.Relinked);
+ CheckNativeFileLinked(forPublish: true);
+
+ void CheckNativeFileLinked(bool forPublish)
+ {
+ // very crude way to check that the native file was linked in
+ // needed because we don't run the blazor app yet
+ string objBuildDir = Path.Combine(_projectDir!, "obj", config, "net6.0", "wasm", forPublish ? "for-publish" : "for-build");
+ string pinvokeTableHPath = Path.Combine(objBuildDir, "pinvoke-table.h");
+ Assert.True(File.Exists(pinvokeTableHPath), $"Could not find {pinvokeTableHPath}");
+
+ string pinvokeTableHContents = File.ReadAllText(pinvokeTableHPath);
+ string pattern = $"\"cpp_add\".*{id}";
+ Assert.True(Regex.IsMatch(pinvokeTableHContents, pattern),
+ $"Could not find {pattern} in {pinvokeTableHPath}");
+ }
+ }
private string CreateProjectWithNativeReference(string id)
{
CreateBlazorWasmTemplateProject(id);