-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from stavroskasidis/feature/remove-publish-issue
Feature/remove publish issue
- Loading branch information
Showing
9 changed files
with
103 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
namespace BlazorWasmAntivirusProtection.Tasks | ||
{ | ||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.IO.Compression; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Text; | ||
|
||
public class CleanOldDlls : Task | ||
{ | ||
[Required] | ||
public string IntermediateLinkDir { get; set; } | ||
|
||
public override bool Execute() | ||
{ | ||
if (!Directory.Exists(IntermediateLinkDir)) return true; | ||
|
||
var linkSemaphore = Path.Combine(IntermediateLinkDir, "Link.semaphore"); | ||
var existingDll = Directory.GetFiles(IntermediateLinkDir, "*.dll").FirstOrDefault(); | ||
if (File.Exists(linkSemaphore) && existingDll != null && IsDllHeaderBz(existingDll)) | ||
{ | ||
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; | ||
} | ||
|
||
bool IsDllHeaderBz(string fn) | ||
{ | ||
using var fs = File.Open(fn, FileMode.Open, FileAccess.ReadWrite); | ||
using var reader = new BinaryReader(fs); | ||
var buffer = new byte[2]; | ||
reader.Read(buffer, 0 , buffer.Length); | ||
|
||
var bz = Encoding.ASCII.GetBytes("BZ"); | ||
return bz[0] == buffer[0] && bz[1] == buffer[1]; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters