diff --git a/src/Components/WebAssembly/Build/src/build/netstandard1.0/Microsoft.AspNetCore.Components.WebAssembly.Build.props b/src/Components/WebAssembly/Build/src/build/netstandard1.0/Microsoft.AspNetCore.Components.WebAssembly.Build.props
index f20d90334c..a85c05ce87 100644
--- a/src/Components/WebAssembly/Build/src/build/netstandard1.0/Microsoft.AspNetCore.Components.WebAssembly.Build.props
+++ b/src/Components/WebAssembly/Build/src/build/netstandard1.0/Microsoft.AspNetCore.Components.WebAssembly.Build.props
@@ -1,3 +1,7 @@
+
+
+ true
+
diff --git a/src/Components/WebAssembly/Build/src/targets/Blazor.MonoRuntime.targets b/src/Components/WebAssembly/Build/src/targets/Blazor.MonoRuntime.targets
index 2129568bac..b0aa8bb89c 100644
--- a/src/Components/WebAssembly/Build/src/targets/Blazor.MonoRuntime.targets
+++ b/src/Components/WebAssembly/Build/src/targets/Blazor.MonoRuntime.targets
@@ -272,6 +272,15 @@
+
+
+
+
+
-
+
+
+
+
+
+
diff --git a/src/Components/WebAssembly/Build/test/BuildIntegrationTests/PublishIntegrationTest.cs b/src/Components/WebAssembly/Build/test/BuildIntegrationTests/PublishIntegrationTest.cs
index c727b1dad5..d6bd0613ca 100644
--- a/src/Components/WebAssembly/Build/test/BuildIntegrationTests/PublishIntegrationTest.cs
+++ b/src/Components/WebAssembly/Build/test/BuildIntegrationTests/PublishIntegrationTest.cs
@@ -178,18 +178,23 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
}
[Fact]
- public async Task Publish_HostedApp_Works()
+ public async Task Publish_HostedApp_WithLinkOnBuildTrue_Works()
{
// Arrange
using var project = ProjectDirectory.Create("blazorhosted", additionalProjects: new[] { "standalone", "razorclasslibrary", });
project.TargetFramework = "netcoreapp3.1";
var result = await MSBuildProcessManager.DotnetMSBuild(project, "Publish");
+ AddSiblingProjectFileContent(project, @"
+
+ true
+");
Assert.BuildPassed(result);
var publishDirectory = project.PublishOutputDirectory;
// Make sure the main project exists
Assert.FileExists(result, publishDirectory, "blazorhosted.dll");
+ Assert.FileExists(result, publishDirectory, "RazorClassLibrary.dll");
var blazorPublishDirectory = Path.Combine(publishDirectory, "wwwroot");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.boot.json");
@@ -198,6 +203,10 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
Assert.FileExists(result, blazorPublishDirectory, "_framework", "wasm", DotNetJsFileName);
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
+ // Verify project references appear as static web assets
+ Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "RazorClassLibrary.dll");
+ // Also verify project references to the server project appear in the publish output
+ Assert.FileExists(result, publishDirectory, "RazorClassLibrary.dll");
// Verify static assets are in the publish directory
Assert.FileExists(result, blazorPublishDirectory, "index.html");
@@ -224,7 +233,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
using var project = ProjectDirectory.Create("blazorhosted", additionalProjects: new[] { "standalone", "razorclasslibrary", });
project.TargetFramework = "netcoreapp3.1";
- AddSiblingProjectFileContent(@"
+ AddSiblingProjectFileContent(project, @"
false
");
@@ -241,12 +250,18 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
// Make sure the main project exists
Assert.FileExists(result, publishDirectory, "blazorhosted.dll");
+ // Verification for https://github.com/dotnet/aspnetcore/issues/19926. Verify binaries for projects
+ // referenced by the Hosted project appear in the publish directory
+ Assert.FileExists(result, publishDirectory, "RazorClassLibrary.dll");
+ Assert.FileExists(result, publishDirectory, "standalone.dll");
+
var blazorPublishDirectory = Path.Combine(publishDirectory, "wwwroot");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.boot.json");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.webassembly.js");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "wasm", DotNetJsFileName);
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "standalone.dll");
+ Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "RazorClassLibrary.dll");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
// Verify static assets are in the publish directory
@@ -268,14 +283,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
serviceWorkerContent: "// This is the production service worker",
assetsManifestPath: "custom-service-worker-assets.js");
- void AddSiblingProjectFileContent(string content)
- {
- var path = Path.Combine(project.SolutionPath, "standalone", "standalone.csproj");
- var existing = File.ReadAllText(path);
- var updated = existing.Replace("", content);
- File.WriteAllText(path, updated);
}
- }
[Fact]
public async Task Publish_HostedApp_WithNoBuild_Works()
@@ -319,6 +327,14 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
assetsManifestPath: "custom-service-worker-assets.js");
}
+ private static void AddSiblingProjectFileContent(ProjectDirectory project, string content)
+ {
+ var path = Path.Combine(project.SolutionPath, "standalone", "standalone.csproj");
+ var existing = File.ReadAllText(path);
+ var updated = existing.Replace("", content);
+ File.WriteAllText(path, updated);
+ }
+
private static void VerifyBootManifestHashes(MSBuildResult result, string blazorPublishDirectory)
{
var bootManifestResolvedPath = Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.boot.json");
diff --git a/src/Components/WebAssembly/Build/testassets/blazorhosted/Program.cs b/src/Components/WebAssembly/Build/testassets/blazorhosted/Program.cs
index e2efcc0c74..a90f4db291 100644
--- a/src/Components/WebAssembly/Build/testassets/blazorhosted/Program.cs
+++ b/src/Components/WebAssembly/Build/testassets/blazorhosted/Program.cs
@@ -10,6 +10,7 @@ namespace blazorhosted.Server
public static void Main(string[] args)
{
Console.WriteLine(typeof(IWebHost));
+ GC.KeepAlive(typeof(RazorClassLibrary.Class1));
}
}
}