From b02978e0d86ba4be72103a698313cfbb5cfca749 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 5 Mar 2020 14:36:32 -0800 Subject: [PATCH] React to dotnet.js having a version number (#19603) --- .../src/targets/Blazor.MonoRuntime.targets | 22 +-------------- .../BuildIntegrationTest.cs | 5 ++-- .../PublishIntegrationTest.cs | 13 ++++----- .../WebAssemblyRuntimePackage.cs | 27 +++++++++++++++++++ ....Components.WebAssembly.Build.Tests.csproj | 7 ++++- 5 files changed, 44 insertions(+), 30 deletions(-) create mode 100644 src/Components/WebAssembly/Build/test/BuildIntegrationTests/WebAssemblyRuntimePackage.cs diff --git a/src/Components/WebAssembly/Build/src/targets/Blazor.MonoRuntime.targets b/src/Components/WebAssembly/Build/src/targets/Blazor.MonoRuntime.targets index ab219caa61..644711caea 100644 --- a/src/Components/WebAssembly/Build/src/targets/Blazor.MonoRuntime.targets +++ b/src/Components/WebAssembly/Build/src/targets/Blazor.MonoRuntime.targets @@ -121,34 +121,14 @@ - - - 3.2.0-preview2 - - - <_DotNetWasmRuntimeFile Include="$(ComponentsWebAssemblyRuntimePath)*.wasm" /> + <_DotNetWasmRuntimeFile Include="$(ComponentsWebAssemblyRuntimePath)*" /> <_BlazorOutputWithTargetPath Include="@(_DotNetWasmRuntimeFile)"> $(_BlazorRuntimeWasmOutputPath)%(FileName)%(Extension) runtime %(FileName)%(Extension) - <_DotNetWasmJsFile Include="$(ComponentsWebAssemblyRuntimePath)*.js" /> - <_BlazorOutputWithTargetPath Include="@(_DotNetWasmJsFile)"> - $(_BlazorRuntimeWasmOutputPath)%(FileName).$(TemporaryDotNetJsFileVersion)%(Extension) - runtime - %(FileName).$(TemporaryDotNetJsFileVersion)%(Extension) - - <_BlazorJSFile Include="$(_BlazorJSPath)" /> <_BlazorJSFile Include="$(_BlazorJSMapPath)" Condition="Exists('$(_BlazorJSMapPath)')" /> <_BlazorOutputWithTargetPath Include="@(_BlazorJSFile)"> diff --git a/src/Components/WebAssembly/Build/test/BuildIntegrationTests/BuildIntegrationTest.cs b/src/Components/WebAssembly/Build/test/BuildIntegrationTests/BuildIntegrationTest.cs index 30eefd3458..0f87f1e63c 100644 --- a/src/Components/WebAssembly/Build/test/BuildIntegrationTests/BuildIntegrationTest.cs +++ b/src/Components/WebAssembly/Build/test/BuildIntegrationTests/BuildIntegrationTest.cs @@ -4,6 +4,7 @@ using System.IO; using System.Threading.Tasks; using Xunit; +using static Microsoft.AspNetCore.Components.WebAssembly.Build.WebAssemblyRuntimePackage; namespace Microsoft.AspNetCore.Components.WebAssembly.Build { @@ -23,7 +24,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "blazor.boot.json"); Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "blazor.webassembly.js"); Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "wasm", "dotnet.wasm"); - Assert.FileCountEquals(result, 1, Path.Combine(buildOutputDirectory, "wwwroot", "_framework", "wasm"), "dotnet.*.js"); + Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "wasm", DotNetJsFileName); Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "standalone.dll"); Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output. @@ -71,7 +72,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "blazor.boot.json"); Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "blazor.webassembly.js"); Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "wasm", "dotnet.wasm"); - Assert.FileCountEquals(result, 1, Path.Combine(buildOutputDirectory, "wwwroot", "_framework", "wasm"), "dotnet.*.js"); + Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "wasm", DotNetJsFileName); Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "standalone.dll"); Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output. } diff --git a/src/Components/WebAssembly/Build/test/BuildIntegrationTests/PublishIntegrationTest.cs b/src/Components/WebAssembly/Build/test/BuildIntegrationTests/PublishIntegrationTest.cs index b81ac7ada2..32eaa82167 100644 --- a/src/Components/WebAssembly/Build/test/BuildIntegrationTests/PublishIntegrationTest.cs +++ b/src/Components/WebAssembly/Build/test/BuildIntegrationTests/PublishIntegrationTest.cs @@ -4,6 +4,7 @@ using System.IO; using System.Threading.Tasks; using Xunit; +using static Microsoft.AspNetCore.Components.WebAssembly.Build.WebAssemblyRuntimePackage; namespace Microsoft.AspNetCore.Components.WebAssembly.Build { @@ -24,7 +25,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build 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.FileCountEquals(result, 1, Path.Combine(blazorPublishDirectory, "_framework", "wasm"), "dotnet.*.js"); + 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. @@ -64,7 +65,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build 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.FileCountEquals(result, 1, Path.Combine(blazorPublishDirectory, "_framework", "wasm"), "dotnet.*.js"); + 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. @@ -102,7 +103,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build 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.FileCountEquals(result, 1, Path.Combine(blazorPublishDirectory, "_framework", "wasm"), "dotnet.*.js"); + 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. @@ -164,7 +165,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build 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.FileCountEquals(result, 1, Path.Combine(blazorPublishDirectory, "_framework", "wasm"), "dotnet.*.js"); + 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. @@ -208,7 +209,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build 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.FileCountEquals(result, 1, Path.Combine(blazorPublishDirectory, "_framework", "wasm"), "dotnet.*.js"); + 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. @@ -254,7 +255,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build 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.FileCountEquals(result, 1, Path.Combine(blazorPublishDirectory, "_framework", "wasm"), "dotnet.*.js"); + 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. diff --git a/src/Components/WebAssembly/Build/test/BuildIntegrationTests/WebAssemblyRuntimePackage.cs b/src/Components/WebAssembly/Build/test/BuildIntegrationTests/WebAssemblyRuntimePackage.cs new file mode 100644 index 0000000000..d95ba1e41c --- /dev/null +++ b/src/Components/WebAssembly/Build/test/BuildIntegrationTests/WebAssemblyRuntimePackage.cs @@ -0,0 +1,27 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Reflection; + +namespace Microsoft.AspNetCore.Components.WebAssembly.Build +{ + internal static class WebAssemblyRuntimePackage + { + public static readonly string ComponentsWebAssemblyRuntimePackageVersion; + public static readonly string DotNetJsFileName; + + static WebAssemblyRuntimePackage() + { + ComponentsWebAssemblyRuntimePackageVersion = typeof(WebAssemblyRuntimePackage) + .Assembly + .GetCustomAttributes() + .FirstOrDefault(f => f.Key == "Testing.MicrosoftAspNetCoreComponentsWebAssemblyRuntimePackageVersion") + ?.Value + ?? throw new InvalidOperationException("Testing.MicrosoftAspNetCoreComponentsWebAssemblyRuntimePackageVersion was not found"); + + DotNetJsFileName = $"dotnet.{ComponentsWebAssemblyRuntimePackageVersion}.js"; + } + } +} diff --git a/src/Components/WebAssembly/Build/test/Microsoft.AspNetCore.Components.WebAssembly.Build.Tests.csproj b/src/Components/WebAssembly/Build/test/Microsoft.AspNetCore.Components.WebAssembly.Build.Tests.csproj index 00ebfae26e..035bc4ad6c 100644 --- a/src/Components/WebAssembly/Build/test/Microsoft.AspNetCore.Components.WebAssembly.Build.Tests.csproj +++ b/src/Components/WebAssembly/Build/test/Microsoft.AspNetCore.Components.WebAssembly.Build.Tests.csproj @@ -1,4 +1,4 @@ - + $(DefaultNetCoreTargetFramework) @@ -39,6 +39,11 @@ <_Parameter1>Testing.RepoRoot <_Parameter2>$(RepoRoot) + + + <_Parameter1>Testing.MicrosoftAspNetCoreComponentsWebAssemblyRuntimePackageVersion + <_Parameter2>$(MicrosoftAspNetCoreComponentsWebAssemblyRuntimePackageVersion) +