From 139ef9089c16a7256c6b9a9801e90994902af9bd Mon Sep 17 00:00:00 2001 From: stavroskasidis Date: Tue, 13 Dec 2022 19:14:41 +0200 Subject: [PATCH 1/5] Created recompress satellite assemblies task --- sampleapps/Directory.Build.props | 2 +- .../RecompressSatelliteAssemblies.cs | 60 +++++++++++++++ .../RenameDlls.cs | 66 +--------------- .../Tools.cs | 75 +++++++++++++++++++ src/BlazorWasmAntivirusProtection.sln | 3 + .../BlazorWasmAntivirusProtection.csproj | 2 +- .../BlazorWasmAntivirusProtection.targets | 6 ++ 7 files changed, 149 insertions(+), 65 deletions(-) create mode 100644 src/BlazorWasmAntivirusProtection.Tasks/RecompressSatelliteAssemblies.cs create mode 100644 src/BlazorWasmAntivirusProtection.Tasks/Tools.cs diff --git a/sampleapps/Directory.Build.props b/sampleapps/Directory.Build.props index 2baa92a..a390234 100644 --- a/sampleapps/Directory.Build.props +++ b/sampleapps/Directory.Build.props @@ -2,7 +2,7 @@ net7.0 7.0.* - 2.3.0-test + 2.4.0-test \ No newline at end of file diff --git a/src/BlazorWasmAntivirusProtection.Tasks/RecompressSatelliteAssemblies.cs b/src/BlazorWasmAntivirusProtection.Tasks/RecompressSatelliteAssemblies.cs new file mode 100644 index 0000000..4070524 --- /dev/null +++ b/src/BlazorWasmAntivirusProtection.Tasks/RecompressSatelliteAssemblies.cs @@ -0,0 +1,60 @@ +namespace BlazorWasmAntivirusProtection.Tasks +{ + using Microsoft.Build.Framework; + using Microsoft.Build.Utilities; + using System; + using System.Diagnostics; + using System.IO; + using System.IO.Compression; + using System.Linq; + using System.Net.Http; + using System.Security.Cryptography; + using System.Text; + using System.Text.Json; + + public class RecompressSatelliteAssemblies : Task + { + [Required] + public string PublishDir { get; set; } + [Required] + public string BrotliCompressToolPath { get; set; } + + public string CompressionLevel { get; set; } + + public override bool Execute() + { +#if DEBUG + System.Diagnostics.Debugger.Launch(); +#endif + Log.LogMessage(MessageImportance.High, $"BlazorWasmAntivirusProtection: Recompressing satellite assemblies"); + var frameworkDirs = Directory.GetDirectories(PublishDir, "_framework", SearchOption.AllDirectories); + foreach(var frameworkDir in frameworkDirs) + { + foreach (var file in Directory.GetFiles(frameworkDir, "*.*", SearchOption.AllDirectories)) + { + if (file.EndsWith(".resources.bin")) + { + var gzFile = $"{file}.gz"; + var brFile = $"{file}.br"; + if (File.Exists(gzFile)) + { + Log.LogMessage(MessageImportance.High, $"BlazorWasmAntivirusProtection: Recompressing \"{gzFile}\""); + if (!Tools.GZipCompress(file, gzFile, Log)) return false; + } + if (File.Exists(brFile)) + { + Log.LogMessage(MessageImportance.High, $"BlazorWasmAntivirusProtection: Recompressing \"{brFile}\""); + if (!Tools.BrotliCompress(file, gzFile, BrotliCompressToolPath, CompressionLevel, Log)) return false; + } + } + } + } + + Log.LogMessage(MessageImportance.High, $"BlazorWasmAntivirusProtection: Recompressing satellite assemblies finished"); + + return true; + } + + + } +} diff --git a/src/BlazorWasmAntivirusProtection.Tasks/RenameDlls.cs b/src/BlazorWasmAntivirusProtection.Tasks/RenameDlls.cs index 1663709..24d9f6f 100644 --- a/src/BlazorWasmAntivirusProtection.Tasks/RenameDlls.cs +++ b/src/BlazorWasmAntivirusProtection.Tasks/RenameDlls.cs @@ -66,7 +66,7 @@ public override bool Execute() serviceWorkerAssets = serviceWorkerAssets.Replace(".dll", $".{RenameDllsTo}"); var assetsManifest = JsonSerializer.Deserialize(serviceWorkerAssets.Replace("self.assetsManifest = ", "").Trim().TrimEnd(';')); var bootJsonAssetEntry = assetsManifest.assets.First(x => x.url.EndsWith("blazor.boot.json")); - bootJsonAssetEntry.hash = $"sha256-{ComputeSha256Hash(bootJson)}"; + bootJsonAssetEntry.hash = $"sha256-{Tools.ComputeSha256Hash(bootJson)}"; //var bootJsonModel = JsonSerializer.Deserialize(bootJson); //foreach(var assembly in bootJsonModel.resources.assembly) //{ @@ -82,7 +82,7 @@ public override bool Execute() if (File.Exists(bootJsonGzPath) && BlazorEnableCompression) { Log.LogMessage(MessageImportance.High, $"BlazorWasmAntivirusProtection: Recompressing \"{bootJsonGzPath}\""); - if(!GZipCompress(bootJsonPath, bootJsonGzPath)) + if(!Tools.GZipCompress(bootJsonPath, bootJsonGzPath,Log)) { return false; } @@ -90,7 +90,7 @@ public override bool Execute() if (File.Exists(bootJsonBrPath) && BlazorEnableCompression) { Log.LogMessage(MessageImportance.High, $"BlazorWasmAntivirusProtection: Recompressing \"{bootJsonBrPath}\""); - if(!BrotliCompress(bootJsonPath, bootJsonBrPath)) + if(!Tools.BrotliCompress(bootJsonPath, bootJsonBrPath, BrotliCompressToolPath, CompressionLevel, Log)) { return false; } @@ -101,65 +101,5 @@ public override bool Execute() return true; } - - private bool GZipCompress(string bootJsonPath, string bootJsonGzPath) - { - try - { - File.Delete(bootJsonGzPath); - using var fileStream = File.OpenRead(bootJsonPath); - using var stream = File.Create(bootJsonGzPath); - using var destination = new GZipStream(stream, System.IO.Compression.CompressionLevel.Optimal); - fileStream.CopyTo(destination); - } - catch (Exception ex) - { - if (File.Exists(bootJsonGzPath)) - { - File.Delete(bootJsonGzPath); - } - Log.LogErrorFromException(ex, true, true, null); - return false; - } - return true; - } - - private bool BrotliCompress(string bootJsonPath, string bootJsonBrPath) - { - try - { - // NOTE: This MSBuild Custom Task will run not only on .NET 6 or later but also on .NET Framework 4.x. - // Therefore the `BrotliStream` class is not usable in this MSBuild Custom Task due to - // the `BrotliStream` class is not provided on.NET Framework.Instead, we can do that - // with execution as an out process. - var startInfo = new ProcessStartInfo - { - FileName = "dotnet", - Arguments = $"exec \"{BrotliCompressToolPath}\" \"{bootJsonPath}\" \"{bootJsonBrPath}\" \"{CompressionLevel}\"" - }; - Log.LogMessage(MessageImportance.Low, $"{startInfo.FileName} {startInfo.Arguments}"); - var process = Process.Start(startInfo); - process.WaitForExit(); - if (process.ExitCode != 0) - throw new Exception($"The exit code of recompressing with Brotli command was not 0. (it was {process.ExitCode})"); - } - catch (Exception ex) - { - if (File.Exists(bootJsonBrPath)) - { - File.Delete(bootJsonBrPath); - } - Log.LogErrorFromException(ex, true, true, null); - return false; - } - return true; - } - - string ComputeSha256Hash(string rawData) - { - using var sha256Hash = SHA256.Create(); - byte[] hash = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(rawData)); - return Convert.ToBase64String(hash); - } } } diff --git a/src/BlazorWasmAntivirusProtection.Tasks/Tools.cs b/src/BlazorWasmAntivirusProtection.Tasks/Tools.cs new file mode 100644 index 0000000..0fac189 --- /dev/null +++ b/src/BlazorWasmAntivirusProtection.Tasks/Tools.cs @@ -0,0 +1,75 @@ +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.IO.Compression; +using System.Security.Cryptography; +using System.Text; + +namespace BlazorWasmAntivirusProtection.Tasks +{ + public static class Tools + { + public static bool GZipCompress(string source, string target, TaskLoggingHelper log) + { + try + { + File.Delete(target); + using var fileStream = File.OpenRead(source); + using var stream = File.Create(target); + using var destination = new GZipStream(stream, CompressionLevel.Optimal); + fileStream.CopyTo(destination); + } + catch (Exception ex) + { + if (File.Exists(target)) + { + File.Delete(target); + } + log.LogErrorFromException(ex, true, true, null); + return false; + } + return true; + } + + public static bool BrotliCompress(string source, string target, string brotliCompressToolPath, string compressionLevel, TaskLoggingHelper log) + { + try + { + // NOTE: This MSBuild Custom Task will run not only on .NET 6 or later but also on .NET Framework 4.x. + // Therefore the `BrotliStream` class is not usable in this MSBuild Custom Task due to + // the `BrotliStream` class is not provided on.NET Framework.Instead, we can do that + // with execution as an out process. + var startInfo = new ProcessStartInfo + { + FileName = "dotnet", + Arguments = $"exec \"{brotliCompressToolPath}\" \"{source}\" \"{target}\" \"{compressionLevel}\"" + }; + log.LogMessage(MessageImportance.Low, $"{startInfo.FileName} {startInfo.Arguments}"); + var process = Process.Start(startInfo); + process.WaitForExit(); + if (process.ExitCode != 0) + throw new Exception($"The exit code of recompressing with Brotli command was not 0. (it was {process.ExitCode})"); + } + catch (Exception ex) + { + if (File.Exists(target)) + { + File.Delete(target); + } + log.LogErrorFromException(ex, true, true, null); + return false; + } + return true; + } + + public static string ComputeSha256Hash(string rawData) + { + using var sha256Hash = SHA256.Create(); + byte[] hash = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(rawData)); + return Convert.ToBase64String(hash); + } + } +} diff --git a/src/BlazorWasmAntivirusProtection.sln b/src/BlazorWasmAntivirusProtection.sln index 116c1ac..ffdda29 100644 --- a/src/BlazorWasmAntivirusProtection.sln +++ b/src/BlazorWasmAntivirusProtection.sln @@ -8,6 +8,9 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorWasmAntivirusProtection.Tasks", "BlazorWasmAntivirusProtection.Tasks\BlazorWasmAntivirusProtection.Tasks.csproj", "{9B4ECABA-1FF3-4B4A-9223-DBBE1D1B1745}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SampleApps", "SampleApps", "{B6087F3A-2586-4098-BD69-449619BEA560}" + ProjectSection(SolutionItems) = preProject + ..\sampleapps\Directory.Build.props = ..\sampleapps\Directory.Build.props + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BlazorHostedSampleApp", "BlazorHostedSampleApp", "{B0BE31C9-49A3-4DD5-9A92-218F35C2AF35}" EndProject diff --git a/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj b/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj index 06bef72..60767fc 100644 --- a/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj +++ b/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj @@ -11,7 +11,7 @@ https://github.com/stavroskasidis/BlazorWasmAntivirusProtection This package attempts to guard against false positives from antiviruses that flag Blazor Wasm as malware $(VersionSuffix) - 2.3.0 + 2.4.0 $(Version)-$(VersionSuffix) diff --git a/src/BlazorWasmAntivirusProtection/build/net7.0/BlazorWasmAntivirusProtection.targets b/src/BlazorWasmAntivirusProtection/build/net7.0/BlazorWasmAntivirusProtection.targets index 51a5baa..b115fb3 100644 --- a/src/BlazorWasmAntivirusProtection/build/net7.0/BlazorWasmAntivirusProtection.targets +++ b/src/BlazorWasmAntivirusProtection/build/net7.0/BlazorWasmAntivirusProtection.targets @@ -5,6 +5,8 @@ AssemblyFile="$(MSBuildThisProjectFileDirectory)..\..\tasks\BlazorWasmAntivirusProtection.Tasks.dll" /> + $(ComputeBlazorExtensionsDependsOn);_ObfuscateDlls @@ -38,6 +40,10 @@ BlazorEnableCompression="$(BlazorEnableCompression)" CompressionLevel="$(_BlazorBrotliCompressionLevel)" BrotliCompressToolPath="$(_BlazorWAPBrotliCompressDll)"> + \ No newline at end of file From 6a3223c4482675df1b7558dd9a420bb102de0914 Mon Sep 17 00:00:00 2001 From: stavroskasidis Date: Tue, 13 Dec 2022 19:49:10 +0200 Subject: [PATCH 2/5] Added recompression for satellite assemblies (the gziped version was the original before obfuscation) --- .../BlazorHostedSampleApp.Client.csproj | 3 +- .../Client/Pages/Index.razor | 6 + .../Client/wwwroot/index.html | 2 +- .../SampleAppsShared.Localization.csproj | 18 +++ .../StringResources.Designer.cs | 72 ++++++++++ .../StringResources.el-GR.resx | 123 ++++++++++++++++++ .../StringResources.resx | 123 ++++++++++++++++++ ...mAntivirusProtection.BrotliCompress.csproj | 2 +- .../RecompressSatelliteAssemblies.cs | 11 +- src/BlazorWasmAntivirusProtection.sln | 10 ++ .../BlazorWasmAntivirusProtection.csproj | 15 +-- .../BlazorWasmAntivirusProtection.targets | 4 +- 12 files changed, 368 insertions(+), 21 deletions(-) create mode 100644 sampleapps/SampleAppsShared.Localization/SampleAppsShared.Localization.csproj create mode 100644 sampleapps/SampleAppsShared.Localization/StringResources.Designer.cs create mode 100644 sampleapps/SampleAppsShared.Localization/StringResources.el-GR.resx create mode 100644 sampleapps/SampleAppsShared.Localization/StringResources.resx rename src/BlazorWasmAntivirusProtection/build/{net7.0 => net6.0}/BlazorWasmAntivirusProtection.targets (96%) diff --git a/sampleapps/BlazorHostedSampleApp/Client/BlazorHostedSampleApp.Client.csproj b/sampleapps/BlazorHostedSampleApp/Client/BlazorHostedSampleApp.Client.csproj index e21eb4a..ec4d5d6 100644 --- a/sampleapps/BlazorHostedSampleApp/Client/BlazorHostedSampleApp.Client.csproj +++ b/sampleapps/BlazorHostedSampleApp/Client/BlazorHostedSampleApp.Client.csproj @@ -20,7 +20,8 @@ - + + diff --git a/sampleapps/BlazorHostedSampleApp/Client/Pages/Index.razor b/sampleapps/BlazorHostedSampleApp/Client/Pages/Index.razor index 4f52c79..721d772 100644 --- a/sampleapps/BlazorHostedSampleApp/Client/Pages/Index.razor +++ b/sampleapps/BlazorHostedSampleApp/Client/Pages/Index.razor @@ -1,4 +1,5 @@ @page "/" +@using SampleAppsShared.Localization Index @@ -7,3 +8,8 @@ This page is using the BlazorWasmAntivirusProtection package. More info here. + + +
+ Resources Test: @StringResources.TestString +
\ No newline at end of file diff --git a/sampleapps/BlazorHostedSampleApp/Client/wwwroot/index.html b/sampleapps/BlazorHostedSampleApp/Client/wwwroot/index.html index 49a2b8a..32f1522 100644 --- a/sampleapps/BlazorHostedSampleApp/Client/wwwroot/index.html +++ b/sampleapps/BlazorHostedSampleApp/Client/wwwroot/index.html @@ -30,7 +30,7 @@ var total = 0; var loaded = 0; var loading = {}; - var culture = "en-US"; + var culture = "el-GR"; Blazor.start({ applicationCulture: culture, loadBootResource: function (type, name, defaultUri, integrity) { diff --git a/sampleapps/SampleAppsShared.Localization/SampleAppsShared.Localization.csproj b/sampleapps/SampleAppsShared.Localization/SampleAppsShared.Localization.csproj new file mode 100644 index 0000000..7ab3be5 --- /dev/null +++ b/sampleapps/SampleAppsShared.Localization/SampleAppsShared.Localization.csproj @@ -0,0 +1,18 @@ + + + + + True + True + StringResources.resx + + + + + + PublicResXFileCodeGenerator + StringResources.Designer.cs + + + + diff --git a/sampleapps/SampleAppsShared.Localization/StringResources.Designer.cs b/sampleapps/SampleAppsShared.Localization/StringResources.Designer.cs new file mode 100644 index 0000000..e94791c --- /dev/null +++ b/sampleapps/SampleAppsShared.Localization/StringResources.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleAppsShared.Localization { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class StringResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal StringResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SampleAppsShared.Localization.StringResources", typeof(StringResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Test string. + /// + public static string TestString { + get { + return ResourceManager.GetString("TestString", resourceCulture); + } + } + } +} diff --git a/sampleapps/SampleAppsShared.Localization/StringResources.el-GR.resx b/sampleapps/SampleAppsShared.Localization/StringResources.el-GR.resx new file mode 100644 index 0000000..1fead09 --- /dev/null +++ b/sampleapps/SampleAppsShared.Localization/StringResources.el-GR.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Δοκιμαστικό string + + \ No newline at end of file diff --git a/sampleapps/SampleAppsShared.Localization/StringResources.resx b/sampleapps/SampleAppsShared.Localization/StringResources.resx new file mode 100644 index 0000000..48650c0 --- /dev/null +++ b/sampleapps/SampleAppsShared.Localization/StringResources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Test string + + \ No newline at end of file diff --git a/src/BlazorWasmAntivirusProtection.BrotliCompress/BlazorWasmAntivirusProtection.BrotliCompress.csproj b/src/BlazorWasmAntivirusProtection.BrotliCompress/BlazorWasmAntivirusProtection.BrotliCompress.csproj index 0881506..8260501 100644 --- a/src/BlazorWasmAntivirusProtection.BrotliCompress/BlazorWasmAntivirusProtection.BrotliCompress.csproj +++ b/src/BlazorWasmAntivirusProtection.BrotliCompress/BlazorWasmAntivirusProtection.BrotliCompress.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net6.0 enable enable diff --git a/src/BlazorWasmAntivirusProtection.Tasks/RecompressSatelliteAssemblies.cs b/src/BlazorWasmAntivirusProtection.Tasks/RecompressSatelliteAssemblies.cs index 4070524..9bc4667 100644 --- a/src/BlazorWasmAntivirusProtection.Tasks/RecompressSatelliteAssemblies.cs +++ b/src/BlazorWasmAntivirusProtection.Tasks/RecompressSatelliteAssemblies.cs @@ -23,9 +23,9 @@ public class RecompressSatelliteAssemblies : Task public override bool Execute() { -#if DEBUG - System.Diagnostics.Debugger.Launch(); -#endif +//#if DEBUG +// System.Diagnostics.Debugger.Launch(); +//#endif Log.LogMessage(MessageImportance.High, $"BlazorWasmAntivirusProtection: Recompressing satellite assemblies"); var frameworkDirs = Directory.GetDirectories(PublishDir, "_framework", SearchOption.AllDirectories); foreach(var frameworkDir in frameworkDirs) @@ -35,16 +35,17 @@ public override bool Execute() if (file.EndsWith(".resources.bin")) { var gzFile = $"{file}.gz"; - var brFile = $"{file}.br"; if (File.Exists(gzFile)) { Log.LogMessage(MessageImportance.High, $"BlazorWasmAntivirusProtection: Recompressing \"{gzFile}\""); if (!Tools.GZipCompress(file, gzFile, Log)) return false; } + + var brFile = $"{file}.br"; if (File.Exists(brFile)) { Log.LogMessage(MessageImportance.High, $"BlazorWasmAntivirusProtection: Recompressing \"{brFile}\""); - if (!Tools.BrotliCompress(file, gzFile, BrotliCompressToolPath, CompressionLevel, Log)) return false; + if (!Tools.BrotliCompress(file, brFile, BrotliCompressToolPath, CompressionLevel, Log)) return false; } } } diff --git a/src/BlazorWasmAntivirusProtection.sln b/src/BlazorWasmAntivirusProtection.sln index ffdda29..532d155 100644 --- a/src/BlazorWasmAntivirusProtection.sln +++ b/src/BlazorWasmAntivirusProtection.sln @@ -51,6 +51,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorHostedSampleLazyLoadi EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorWasmAntivirusProtection.BrotliCompress", "BlazorWasmAntivirusProtection.BrotliCompress\BlazorWasmAntivirusProtection.BrotliCompress.csproj", "{DF24E023-EE53-4C3A-B0A2-927CCD39F2AF}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleAppsShared.Localization", "..\sampleapps\SampleAppsShared.Localization\SampleAppsShared.Localization.csproj", "{4722CCB1-8E90-4DBB-95EA-F7927E254BAB}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{775A9613-79F0-4FE9-B61D-718C352544B8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -109,6 +113,10 @@ Global {DF24E023-EE53-4C3A-B0A2-927CCD39F2AF}.Debug|Any CPU.Build.0 = Debug|Any CPU {DF24E023-EE53-4C3A-B0A2-927CCD39F2AF}.Release|Any CPU.ActiveCfg = Release|Any CPU {DF24E023-EE53-4C3A-B0A2-927CCD39F2AF}.Release|Any CPU.Build.0 = Release|Any CPU + {4722CCB1-8E90-4DBB-95EA-F7927E254BAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4722CCB1-8E90-4DBB-95EA-F7927E254BAB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4722CCB1-8E90-4DBB-95EA-F7927E254BAB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4722CCB1-8E90-4DBB-95EA-F7927E254BAB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -127,6 +135,8 @@ Global {4C7F227E-2E90-4D0B-960D-0247DA937117} = {B8531AC8-E394-4875-AB1F-3167F4C7149C} {B8531AC8-E394-4875-AB1F-3167F4C7149C} = {B6087F3A-2586-4098-BD69-449619BEA560} {D1EC6118-9D76-42C1-9F4B-E9819AEC6472} = {B8531AC8-E394-4875-AB1F-3167F4C7149C} + {4722CCB1-8E90-4DBB-95EA-F7927E254BAB} = {775A9613-79F0-4FE9-B61D-718C352544B8} + {775A9613-79F0-4FE9-B61D-718C352544B8} = {B6087F3A-2586-4098-BD69-449619BEA560} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8E715717-C14A-4A09-BE07-93EF8245C66C} diff --git a/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj b/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj index 60767fc..47bfc60 100644 --- a/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj +++ b/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj @@ -1,7 +1,7 @@  - net7.0 + net6.0 enable enable true @@ -17,7 +17,7 @@ - + @@ -25,9 +25,7 @@ - + @@ -36,12 +34,7 @@ - + diff --git a/src/BlazorWasmAntivirusProtection/build/net7.0/BlazorWasmAntivirusProtection.targets b/src/BlazorWasmAntivirusProtection/build/net6.0/BlazorWasmAntivirusProtection.targets similarity index 96% rename from src/BlazorWasmAntivirusProtection/build/net7.0/BlazorWasmAntivirusProtection.targets rename to src/BlazorWasmAntivirusProtection/build/net6.0/BlazorWasmAntivirusProtection.targets index b115fb3..a5b436a 100644 --- a/src/BlazorWasmAntivirusProtection/build/net7.0/BlazorWasmAntivirusProtection.targets +++ b/src/BlazorWasmAntivirusProtection/build/net6.0/BlazorWasmAntivirusProtection.targets @@ -40,10 +40,10 @@ BlazorEnableCompression="$(BlazorEnableCompression)" CompressionLevel="$(_BlazorBrotliCompressionLevel)" BrotliCompressToolPath="$(_BlazorWAPBrotliCompressDll)"> - + \ No newline at end of file From 57461666c966504270a6c0546b16d9a5a0d8a724 Mon Sep 17 00:00:00 2001 From: stavroskasidis Date: Tue, 13 Dec 2022 20:51:20 +0200 Subject: [PATCH 3/5] Fix for hardcoded .bin searching for satellite assembly files. --- .../RecompressSatelliteAssemblies.cs | 12 ++++++++---- .../net6.0/BlazorWasmAntivirusProtection.targets | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/BlazorWasmAntivirusProtection.Tasks/RecompressSatelliteAssemblies.cs b/src/BlazorWasmAntivirusProtection.Tasks/RecompressSatelliteAssemblies.cs index 9bc4667..b259e55 100644 --- a/src/BlazorWasmAntivirusProtection.Tasks/RecompressSatelliteAssemblies.cs +++ b/src/BlazorWasmAntivirusProtection.Tasks/RecompressSatelliteAssemblies.cs @@ -20,19 +20,23 @@ public class RecompressSatelliteAssemblies : Task public string BrotliCompressToolPath { get; set; } public string CompressionLevel { get; set; } + public string RenameDllsTo { get; set; } = "bin"; + public bool DisableRenamingDlls { get; set; } public override bool Execute() { -//#if DEBUG -// System.Diagnostics.Debugger.Launch(); -//#endif + //#if DEBUG + // System.Diagnostics.Debugger.Launch(); + //#endif + + var assembyFilesExtension = DisableRenamingDlls ? "dll" : RenameDllsTo; Log.LogMessage(MessageImportance.High, $"BlazorWasmAntivirusProtection: Recompressing satellite assemblies"); var frameworkDirs = Directory.GetDirectories(PublishDir, "_framework", SearchOption.AllDirectories); foreach(var frameworkDir in frameworkDirs) { foreach (var file in Directory.GetFiles(frameworkDir, "*.*", SearchOption.AllDirectories)) { - if (file.EndsWith(".resources.bin")) + if (file.EndsWith($".resources.{assembyFilesExtension}")) { var gzFile = $"{file}.gz"; if (File.Exists(gzFile)) diff --git a/src/BlazorWasmAntivirusProtection/build/net6.0/BlazorWasmAntivirusProtection.targets b/src/BlazorWasmAntivirusProtection/build/net6.0/BlazorWasmAntivirusProtection.targets index a5b436a..807a4be 100644 --- a/src/BlazorWasmAntivirusProtection/build/net6.0/BlazorWasmAntivirusProtection.targets +++ b/src/BlazorWasmAntivirusProtection/build/net6.0/BlazorWasmAntivirusProtection.targets @@ -40,7 +40,7 @@ BlazorEnableCompression="$(BlazorEnableCompression)" CompressionLevel="$(_BlazorBrotliCompressionLevel)" BrotliCompressToolPath="$(_BlazorWAPBrotliCompressDll)"> - From 026e5b8e8e299fc1f4b16489f0cc5ae38fdc14ca Mon Sep 17 00:00:00 2001 From: stavroskasidis Date: Tue, 13 Dec 2022 20:56:13 +0200 Subject: [PATCH 4/5] Realease notes update --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3d34342..3b8844a 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,13 @@ This work was inspired by the post in https://github.com/dotnet/aspnetcore/issue ## Release Notes -
2.3.0 +
2.4.0 + +>- Fix for gzip satellite assemblies being compressed from original verion instead of obfuscated one. +>- Changed target back to .net 6.0. +
+ +
2.3.0 >- Removed Brotli.NET that depends on native libs and added BrotliCompress tool that uses .net native brotli compression. Fixes [#36](https://github.com/stavroskasidis/BlazorWasmAntivirusProtection/issues/36), [#42](https://github.com/stavroskasidis/BlazorWasmAntivirusProtection/issues/42) From 1cb4ac73c2287ed7f2fcea230a5d9a4e03ab5c90 Mon Sep 17 00:00:00 2001 From: stavroskasidis Date: Tue, 13 Dec 2022 21:18:29 +0200 Subject: [PATCH 5/5] Fix for brotli compression tool if only .net 7 is installed --- .../BlazorWasmAntivirusProtection.BrotliCompress.csproj | 1 + .../BlazorWasmAntivirusProtection.csproj | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/BlazorWasmAntivirusProtection.BrotliCompress/BlazorWasmAntivirusProtection.BrotliCompress.csproj b/src/BlazorWasmAntivirusProtection.BrotliCompress/BlazorWasmAntivirusProtection.BrotliCompress.csproj index 8260501..e621259 100644 --- a/src/BlazorWasmAntivirusProtection.BrotliCompress/BlazorWasmAntivirusProtection.BrotliCompress.csproj +++ b/src/BlazorWasmAntivirusProtection.BrotliCompress/BlazorWasmAntivirusProtection.BrotliCompress.csproj @@ -5,6 +5,7 @@ net6.0 enable enable + Major \ No newline at end of file diff --git a/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj b/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj index 47bfc60..e3409ff 100644 --- a/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj +++ b/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj @@ -34,7 +34,7 @@ - +