From 6a55d00f8f99974fb5750c4cb65697d3a750ea5b Mon Sep 17 00:00:00 2001 From: stavroskasidis Date: Tue, 8 Feb 2022 19:45:44 +0200 Subject: [PATCH] Implemented correct illinker cleaning / Version fix --- README.md | 18 ++++++------------ .../Client/BlazorHostedSampleApp.Client.csproj | 2 +- .../Server/BlazorHostedSampleApp.Server.csproj | 2 +- .../CleanOldDlls.cs | 17 ++++++++--------- .../BlazorWasmAntivirusProtection.csproj | 8 ++------ .../BlazorWasmAntivirusProtection.targets | 4 +--- 6 files changed, 19 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 047655b..7e4cff4 100644 --- a/README.md +++ b/README.md @@ -29,21 +29,10 @@ dotnet add package BlazorWasmAntivirusProtection 2. Publish your app in Release mode and test it! ``` -#Perform a clean first, see "Known Issue" below - -dotnet clean BlazorHostedSampleApp.sln -c Release dotnet publish Server\BlazorHostedSampleApp.Server.csproj -c Release ``` *Nuget package page can be found [here](https://www.nuget.org/packages/BlazorDialog).* -## ⚠️ Known issue ⚠️ -If you try to publish a project after you have already published you have to clean your solution or the publish will fail with the following exception: - -`error MSB4018: The "PInvokeTableGenerator" task failed unexpectedly.` - -This happens because the il linker cannot load the existing modified dlls in the obj folder. -To prevent this error you should perform a clean on your solution before every publish, as displayed above. - ## Configuration The following options allow you to customize the tasks executed by this package. ### **Custom dll rename extension** @@ -73,7 +62,12 @@ This work was inspired by the post in https://github.com/dotnet/aspnetcore/issue ## Release Notes -
1.0 +
1.2 + +>- Fixed sequential publishing issue. +
+ +
1.0 >- Added customization options.
diff --git a/sampleapps/BlazorHostedSampleApp/Client/BlazorHostedSampleApp.Client.csproj b/sampleapps/BlazorHostedSampleApp/Client/BlazorHostedSampleApp.Client.csproj index 4cdf329..7dfcacb 100644 --- a/sampleapps/BlazorHostedSampleApp/Client/BlazorHostedSampleApp.Client.csproj +++ b/sampleapps/BlazorHostedSampleApp/Client/BlazorHostedSampleApp.Client.csproj @@ -15,7 +15,7 @@ - + diff --git a/sampleapps/BlazorHostedSampleApp/Server/BlazorHostedSampleApp.Server.csproj b/sampleapps/BlazorHostedSampleApp/Server/BlazorHostedSampleApp.Server.csproj index 9c22840..c570499 100644 --- a/sampleapps/BlazorHostedSampleApp/Server/BlazorHostedSampleApp.Server.csproj +++ b/sampleapps/BlazorHostedSampleApp/Server/BlazorHostedSampleApp.Server.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/BlazorWasmAntivirusProtection.Tasks/CleanOldDlls.cs b/src/BlazorWasmAntivirusProtection.Tasks/CleanOldDlls.cs index 6d25f33..ebe58c5 100644 --- a/src/BlazorWasmAntivirusProtection.Tasks/CleanOldDlls.cs +++ b/src/BlazorWasmAntivirusProtection.Tasks/CleanOldDlls.cs @@ -5,6 +5,7 @@ namespace BlazorWasmAntivirusProtection.Tasks using System.Diagnostics; using System.IO; using System.IO.Compression; + using System.Linq; using System.Net.Http; using System.Text; @@ -15,20 +16,18 @@ public class CleanOldDlls : Task public override bool Execute() { - Debugger.Launch(); if (!Directory.Exists(IntermediateLinkDir)) return true; - Log.LogMessage(MessageImportance.High, $"BlazorWasmAntivirusProtection: Cleaning old .dll files"); - - foreach(var file in Directory.GetFiles(IntermediateLinkDir, "*.dll")) + var linkSemaphore = Path.Combine(IntermediateLinkDir, "Link.semaphore"); + var existingDll = Directory.GetFiles(IntermediateLinkDir, "*.dll").FirstOrDefault(); + if (File.Exists(linkSemaphore) && existingDll != null && IsDllHeaderBz(existingDll)) { - if (IsDllHeaderBz(file)) - { - File.Delete(file); - } + Log.LogMessage(MessageImportance.High, $"BlazorWasmAntivirusProtection: Cleaning old .dll files"); + //We delete the Link.semaphore file to force a regeneration of objs in the IntermediateLinkDir + //This is to remove remnants of a previous publish + File.Delete(linkSemaphore); } - return true; } diff --git a/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj b/src/BlazorWasmAntivirusProtection/BlazorWasmAntivirusProtection.csproj index 72ada17..966bb61 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) - 1.7.0 + 1.2.0 $(Version)-$(VersionSuffix) @@ -25,11 +25,7 @@ - + diff --git a/src/BlazorWasmAntivirusProtection/build/net6.0/BlazorWasmAntivirusProtection.targets b/src/BlazorWasmAntivirusProtection/build/net6.0/BlazorWasmAntivirusProtection.targets index 22dc012..ab53bbb 100644 --- a/src/BlazorWasmAntivirusProtection/build/net6.0/BlazorWasmAntivirusProtection.targets +++ b/src/BlazorWasmAntivirusProtection/build/net6.0/BlazorWasmAntivirusProtection.targets @@ -8,11 +8,9 @@ $(ComputeBlazorExtensionsDependsOn);_ChangeDllHeaders - _CleanOldDlls;$(WasmNestedPublishAppDependsOn) - - +