diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoAOTCompiler.Task/Sdk/Sdk.props b/src/mono/nuget/Microsoft.NET.Runtime.MonoAOTCompiler.Task/Sdk/Sdk.props index adcad9f50e1186d9a9bcadf2b30733781d480801..a94224b1858fea809ebbd9c7d400d77daf5697aa 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoAOTCompiler.Task/Sdk/Sdk.props +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoAOTCompiler.Task/Sdk/Sdk.props @@ -1,6 +1,7 @@ - $(MSBuildThisFileDirectory)..\tasks\MonoAOTCompiler.dll + $(MSBuildThisFileDirectory)..\tasks\net6.0\MonoAOTCompiler.dll + $(MSBuildThisFileDirectory)..\tasks\net472\MonoAOTCompiler.dll diff --git a/src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Sdk/Sdk.targets b/src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Sdk/Sdk.targets index 9bd74455ac6a896b43ee9d1049ac09d5f40611fa..2c2959c87e53a4986011b18d04d04a09ec605962 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Sdk/Sdk.targets +++ b/src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Sdk/Sdk.targets @@ -1,8 +1,11 @@ - $(MSBuildThisFileDirectory)..\tasks\WasmAppBuilder.dll - $(MSBuildThisFileDirectory)..\tasks\WasmBuildTasks.dll + <_TasksDir Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)..\tasks\net6.0\ + <_TasksDir Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)..\tasks\net472\ + + $(_TasksDir)WasmAppBuilder.dll + $(_TasksDir)WasmBuildTasks.dll diff --git a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs index 108b550725a629177ce685ad82076d36ee64fc08..51acec5216ccd313b3a467187e0d1708f8fc1264 100644 --- a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs +++ b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs @@ -185,7 +185,7 @@ public override bool Execute() if (!Enum.TryParse(Mode, true, out parsedAotMode)) { - Log.LogError($"Unknown Mode value: {Mode}. '{nameof(Mode)}' must be one of: {string.Join(',', Enum.GetNames(typeof(MonoAotMode)))}"); + Log.LogError($"Unknown Mode value: {Mode}. '{nameof(Mode)}' must be one of: {string.Join(",", Enum.GetNames(typeof(MonoAotMode)))}"); return false; } @@ -217,7 +217,7 @@ public override bool Execute() string? monoPaths = null; if (AdditionalAssemblySearchPaths != null) - monoPaths = string.Join(Path.PathSeparator, AdditionalAssemblySearchPaths); + monoPaths = string.Join(Path.PathSeparator.ToString(), AdditionalAssemblySearchPaths); if (DisableParallelAot) { @@ -252,13 +252,13 @@ private bool PrecompileLibrary(ITaskItem assemblyItem, string? monoPaths) var a = assemblyItem.GetMetadata("AotArguments"); if (a != null) { - aotArgs.AddRange(a.Split(";", StringSplitOptions.RemoveEmptyEntries)); + aotArgs.AddRange(a.Split(new char[]{ ';' }, StringSplitOptions.RemoveEmptyEntries)); } var p = assemblyItem.GetMetadata("ProcessArguments"); if (p != null) { - processArgs.AddRange(p.Split(";", StringSplitOptions.RemoveEmptyEntries)); + processArgs.AddRange(p.Split(new char[]{ ';' }, StringSplitOptions.RemoveEmptyEntries)); } Log.LogMessage(MessageImportance.Low, $"[AOT] {assembly}"); diff --git a/src/tasks/AotCompilerTask/MonoAOTCompiler.csproj b/src/tasks/AotCompilerTask/MonoAOTCompiler.csproj index 419a364377d4d0b5c92f9e02a56f73dfe22f99fc..c9bf35cf4739115dcc2c2c30ef168cc8f432b99a 100644 --- a/src/tasks/AotCompilerTask/MonoAOTCompiler.csproj +++ b/src/tasks/AotCompilerTask/MonoAOTCompiler.csproj @@ -1,11 +1,14 @@ - $(NetCoreAppToolCurrent) + $(NetCoreAppToolCurrent);$(TargetFrameworkForNETFramework) Library true false enable $(NoWarn),CA1050 + + + $(NoWarn),CS8604,CS8602 @@ -16,6 +19,7 @@ + @@ -26,7 +30,10 @@ - + <_PublishFramework Remove="@(_PublishFramework)" /> + <_PublishFramework Include="$(TargetFrameworks)" /> + + diff --git a/src/tasks/Common/IsExternalInit.cs b/src/tasks/Common/IsExternalInit.cs new file mode 100644 index 0000000000000000000000000000000000000000..d7be691310347146ea6c8b878bc7ca16a34be252 --- /dev/null +++ b/src/tasks/Common/IsExternalInit.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Runtime.CompilerServices +{ + internal sealed class IsExternalInit { } +} diff --git a/src/tasks/Common/Utils.cs b/src/tasks/Common/Utils.cs index b7c1fd6d91ef313f355ee26e95d304159ea13fe4..78738d59be21676371281ea340a4fb12704f4cdb 100644 --- a/src/tasks/Common/Utils.cs +++ b/src/tasks/Common/Utils.cs @@ -102,6 +102,7 @@ public static string GetEmbeddedResource(string file) return outputBuilder.ToString().Trim('\r', '\n'); } +#if NETCOREAPP public static void DirectoryCopy(string sourceDir, string destDir, Func predicate) { string[] files = Directory.GetFiles(sourceDir, "*", SearchOption.AllDirectories); @@ -118,6 +119,7 @@ public static void DirectoryCopy(string sourceDir, string destDir, Func + + + + net472 + + diff --git a/src/tasks/WasmAppBuilder/WasmAppBuilder.cs b/src/tasks/WasmAppBuilder/WasmAppBuilder.cs index d1cf986b3cccfb7e2f718c30d4166f4abac7b15f..9ef7679c292b6683244986f9d0c960e9af895de5 100644 --- a/src/tasks/WasmAppBuilder/WasmAppBuilder.cs +++ b/src/tasks/WasmAppBuilder/WasmAppBuilder.cs @@ -144,18 +144,18 @@ public override bool Execute () var config = new WasmAppConfig (); // Create app - var asmRootPath = Path.Join(AppDir, config.AssemblyRoot); + var asmRootPath = Path.Combine(AppDir, config.AssemblyRoot); Directory.CreateDirectory(AppDir!); Directory.CreateDirectory(asmRootPath); foreach (var assembly in _assemblies) { - FileCopyChecked(assembly, Path.Join(asmRootPath, Path.GetFileName(assembly)), "Assemblies"); + FileCopyChecked(assembly, Path.Combine(asmRootPath, Path.GetFileName(assembly)), "Assemblies"); if (DebugLevel != 0) { var pdb = assembly; pdb = Path.ChangeExtension(pdb, ".pdb"); if (File.Exists(pdb)) - FileCopyChecked(pdb, Path.Join(asmRootPath, Path.GetFileName(pdb)), "Assemblies"); + FileCopyChecked(pdb, Path.Combine(asmRootPath, Path.GetFileName(pdb)), "Assemblies"); } } @@ -165,10 +165,10 @@ public override bool Execute () if (!FileCopyChecked(item.ItemSpec, dest, "NativeAssets")) return false; } - FileCopyChecked(MainJS!, Path.Join(AppDir, "runtime.js"), string.Empty); + FileCopyChecked(MainJS!, Path.Combine(AppDir, "runtime.js"), string.Empty); var html = @""; - File.WriteAllText(Path.Join(AppDir, "index.html"), html); + File.WriteAllText(Path.Combine(AppDir, "index.html"), html); foreach (var assembly in _assemblies) { @@ -190,16 +190,16 @@ public override bool Execute () string culture = assembly.GetMetadata("CultureName") ?? string.Empty; string fullPath = assembly.GetMetadata("Identity"); string name = Path.GetFileName(fullPath); - string directory = Path.Join(AppDir, config.AssemblyRoot, culture); + string directory = Path.Combine(AppDir, config.AssemblyRoot, culture); Directory.CreateDirectory(directory); - FileCopyChecked(fullPath, Path.Join(directory, name), "SatelliteAssemblies"); + FileCopyChecked(fullPath, Path.Combine(directory, name), "SatelliteAssemblies"); config.Assets.Add(new SatelliteAssemblyEntry(name, culture)); } } if (FilesToIncludeInFileSystem != null) { - string supportFilesDir = Path.Join(AppDir, "supportFiles"); + string supportFilesDir = Path.Combine(AppDir, "supportFiles"); Directory.CreateDirectory(supportFilesDir); var i = 0; @@ -216,7 +216,7 @@ public override bool Execute () var generatedFileName = $"{i++}_{Path.GetFileName(item.ItemSpec)}"; - FileCopyChecked(item.ItemSpec, Path.Join(supportFilesDir, generatedFileName), "FilesToIncludeInFileSystem"); + FileCopyChecked(item.ItemSpec, Path.Combine(supportFilesDir, generatedFileName), "FilesToIncludeInFileSystem"); var asset = new VfsEntry ($"supportFiles/{generatedFileName}") { VirtualPath = targetPath @@ -246,7 +246,7 @@ public override bool Execute () config.Extra[name] = valueObject; } - string monoConfigPath = Path.Join(AppDir, "mono-config.js"); + string monoConfigPath = Path.Combine(AppDir, "mono-config.js"); using (var sw = File.CreateText(monoConfigPath)) { var json = JsonSerializer.Serialize (config, new JsonSerializerOptions { WriteIndented = true }); @@ -284,9 +284,9 @@ private bool TryParseExtraConfigValue(ITaskItem extraItem, out object? valueObje return true; // Try parsing as a quoted string - if (rawValue!.Length > 1 && rawValue![0] == '"' && rawValue![^1] == '"') + if (rawValue!.Length > 1 && rawValue![0] == '"' && rawValue![rawValue!.Length - 1] == '"') { - valueObject = rawValue![1..^1]; + valueObject = rawValue!.Substring(1, rawValue!.Length - 2); return true; } diff --git a/src/tasks/WasmAppBuilder/WasmAppBuilder.csproj b/src/tasks/WasmAppBuilder/WasmAppBuilder.csproj index 0846c59795d1681598cd173979deb5b4d09990a7..e7641b3ab1aad70170b3aa61d23e932c35ae02f5 100644 --- a/src/tasks/WasmAppBuilder/WasmAppBuilder.csproj +++ b/src/tasks/WasmAppBuilder/WasmAppBuilder.csproj @@ -1,9 +1,18 @@ - $(NetCoreAppToolCurrent) + $(NetCoreAppToolCurrent);$(TargetFrameworkForNETFramework) enable $(NoWarn),CA1050 + + + $(NoWarn),CS8604,CS8602 + + + + + + @@ -13,13 +22,29 @@ + AfterTargets="Build"> + + + + <_PublishFramework Include="$(TargetFrameworks)" /> + + + - - + <_PublishFramework Remove="@(_PublishFramework)" /> + <_PublishFramework Include="$(TargetFrameworks)" /> + + + + + + +