From 46e8b8fd23c899d57706ca9be954f15e594b8734 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Mon, 31 Oct 2022 20:23:18 -0400 Subject: [PATCH 1/3] [wasm] Fix analyzer support in templates - Add `[assembly:System.Runtime.Versioning.SupportedOSPlatform("browser")]` to the browser, and console templates. This would allow the analyzers, if enabled, to treat the assembly as one that will run only on browser. - Also, populate `@(SupportedPlatform)` with only `browser`, for *wasm* projects, similar to https://github.com/dotnet/sdk/blob/fef8cedfb6b4ac85a7e135f3e4f155e29cdcbdf1/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.5_0.targets#L75-L79 --- src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs | 7 +++++-- src/mono/wasm/build/WasmApp.targets | 3 +++ .../templates/templates/browser/Properties/AssemblyInfo.cs | 4 ++++ .../templates/templates/console/Properties/AssemblyInfo.cs | 4 ++++ 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 src/mono/wasm/templates/templates/browser/Properties/AssemblyInfo.cs create mode 100644 src/mono/wasm/templates/templates/console/Properties/AssemblyInfo.cs diff --git a/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs b/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs index 5e87669e4cf68a..e1c5207659835e 100644 --- a/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs +++ b/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs @@ -463,7 +463,7 @@ private static string GetNuGetConfigWithLocalPackagesPath(string templatePath, s return contents.Replace(s_nugetInsertionTag, $@""); } - public string CreateWasmTemplateProject(string id, string template = "wasmbrowser", string extraArgs = "") + public string CreateWasmTemplateProject(string id, string template = "wasmbrowser", string extraArgs = "", bool runAnalyzers = true) { InitPaths(id); InitProjectDir(_projectDir, addNuGetSourceForLocalPackages: true); @@ -483,7 +483,10 @@ public string CreateWasmTemplateProject(string id, string template = "wasmbrowse .ExecuteWithCapturedOutput($"new {template} {extraArgs}") .EnsureSuccessful(); - return Path.Combine(_projectDir!, $"{id}.csproj"); + string projectfile = Path.Combine(_projectDir!, $"{id}.csproj"); + if (runAnalyzers) + AddItemsPropertiesToProject("true"); + return projectfile; } public string CreateBlazorWasmTemplateProject(string id) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 5cb9d26781b47f..a2031cab5457f2 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -120,6 +120,9 @@ + + + diff --git a/src/mono/wasm/templates/templates/browser/Properties/AssemblyInfo.cs b/src/mono/wasm/templates/templates/browser/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000000..9ad9b578f20649 --- /dev/null +++ b/src/mono/wasm/templates/templates/browser/Properties/AssemblyInfo.cs @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +[assembly:System.Runtime.Versioning.SupportedOSPlatform("browser")] diff --git a/src/mono/wasm/templates/templates/console/Properties/AssemblyInfo.cs b/src/mono/wasm/templates/templates/console/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000000..9ad9b578f20649 --- /dev/null +++ b/src/mono/wasm/templates/templates/console/Properties/AssemblyInfo.cs @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +[assembly:System.Runtime.Versioning.SupportedOSPlatform("browser")] From 27d0d3952ba018456a3315ee0273a1dd57229d28 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Mon, 31 Oct 2022 20:45:34 -0400 Subject: [PATCH 2/3] [wasm] Add SupportedOSPlatform assembly attribute for all the wasm samples --- src/mono/sample/wasm/CommonAssemblyInfo.cs | 4 ++++ src/mono/sample/wasm/Directory.Build.props | 2 ++ 2 files changed, 6 insertions(+) create mode 100644 src/mono/sample/wasm/CommonAssemblyInfo.cs diff --git a/src/mono/sample/wasm/CommonAssemblyInfo.cs b/src/mono/sample/wasm/CommonAssemblyInfo.cs new file mode 100644 index 00000000000000..9ad9b578f20649 --- /dev/null +++ b/src/mono/sample/wasm/CommonAssemblyInfo.cs @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +[assembly:System.Runtime.Versioning.SupportedOSPlatform("browser")] diff --git a/src/mono/sample/wasm/Directory.Build.props b/src/mono/sample/wasm/Directory.Build.props index 7382a6e5ce8f07..d03dbcf021398d 100644 --- a/src/mono/sample/wasm/Directory.Build.props +++ b/src/mono/sample/wasm/Directory.Build.props @@ -32,6 +32,8 @@ + + From 1e189eca4129adbf9ef448ed4dd611c029b69749 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Mon, 31 Oct 2022 23:53:15 -0400 Subject: [PATCH 3/3] Use the existing provisioning for firefox, instead of duplicating that .. for CI. --- src/libraries/sendtohelix-wasm.targets | 18 +++++------------- src/libraries/sendtohelix.proj | 1 + .../DebuggerTestSuite/DebuggerTestSuite.csproj | 5 +++-- .../Wasm.Debugger.Tests.csproj | 1 + 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/libraries/sendtohelix-wasm.targets b/src/libraries/sendtohelix-wasm.targets index fcdcdad18e301c..12edd38bd05759 100644 --- a/src/libraries/sendtohelix-wasm.targets +++ b/src/libraries/sendtohelix-wasm.targets @@ -38,14 +38,12 @@ $(BuildHelixWorkItemsDependsOn);StageEmSdkForHelix;PrepareForBuildHelixWorkItems_Wasm - $(BuildHelixWorkItemsDependsOn);DownloadFirefoxToSendToHelix false false $(RepoRoot)src\mono\wasm\emsdk\ $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'mono', 'wasm', 'emsdk')) - $(TestArchiveRoot)firefox.zip chrome true @@ -159,17 +157,18 @@ - - + - - + @@ -291,11 +290,4 @@ DestinationFiles="@(_EmSdkFiles -> '$(EmSdkDirForHelixPayload)\%(RecursiveDir)%(FileName)%(Extension)')" SkipUnchangedFiles="true" /> - - - - - - - diff --git a/src/libraries/sendtohelix.proj b/src/libraries/sendtohelix.proj index 60de339e34023a..6aca13e92bc10b 100644 --- a/src/libraries/sendtohelix.proj +++ b/src/libraries/sendtohelix.proj @@ -48,6 +48,7 @@ HelixTargetQueues=$(HelixTargetQueues); BuildTargetFramework=$(BuildTargetFramework) + <_DebuggerHosts Condition="'$(_DebuggerHosts)' == ''">$(DebuggerHost) <_DebuggerHosts Condition="'$(_DebuggerHosts)' == ''">chrome diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestSuite.csproj b/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestSuite.csproj index 68dd92779b0ead..d74faaeb66e2cb 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestSuite.csproj +++ b/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestSuite.csproj @@ -7,8 +7,9 @@ chrome $(DefineConstants);RUN_IN_CHROME windows - true - true + <_ProvisionBrowser Condition="'$(ContinuousIntegrationBuild)' == 'true' or Exists('/.dockerenv')">true + true + true $(OutputPath).runsettings diff --git a/src/mono/wasm/debugger/Wasm.Debugger.Tests/Wasm.Debugger.Tests.csproj b/src/mono/wasm/debugger/Wasm.Debugger.Tests/Wasm.Debugger.Tests.csproj index 2dd8ac14f2bfcb..66490809749c87 100644 --- a/src/mono/wasm/debugger/Wasm.Debugger.Tests/Wasm.Debugger.Tests.csproj +++ b/src/mono/wasm/debugger/Wasm.Debugger.Tests/Wasm.Debugger.Tests.csproj @@ -37,6 +37,7 @@ ArchiveDirForHelix=$(TargetDir); TestArchiveTestsDir=$(TestArchiveTestsDir); ExtractTestClassNamesForHelix=$(ExtractTestClassNamesForHelix); + DebuggerHost=$(DebuggerHost); DotNetForTests=$([MSBuild]::NormalizePath($(DotNetRoot), $(DotNetTool)))" />