stavroskasidis / BlazorWasmAntivirusProtection

Antivirus protection for Blazor Wasm projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The "BlazorWasmAntivirusProtection.Tasks.CleanOldDlls" task could not be loaded

calnastic0 opened this issue · comments

Environment:

  • windows 10
  • visual studio 2022 17.4.0,
  • .net 6
  • BlazorWasmAntivirusProtection version 2.0

To reproduce:

  1. Created a new blazor webassebmly project with Asp.net core hosting, HTTPS and PWA checked.
  2. Installed BlazorWasmAntivirusProtection version 2.0 to both server and client projects
  3. Publish

Ran into this error:
Error The "BlazorWasmAntivirusProtection.Tasks.CleanOldDlls" task could not be loaded from the assembly C:\Users\me\.nuget\packages\blazorwasmantivirusprotection\2.0.0\build\net6.0....\tasks\BlazorWasmAntivirusProtection.Tasks.dll. Could not load file or assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

With my other existing project the error is a little different, marked in bold:
Error The "BlazorWasmAntivirusProtection.Tasks.ObfuscateDlls" task could not be loaded from the assembly C:\Users\me\.nuget\packages\blazorwasmantivirusprotection\1.9.0\build\net6.0....\tasks\BlazorWasmAntivirusProtection.Tasks.dll. Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

I deleted the these folders

  • "C:\Users\me\.nuget\packages\blazorwasmantivirusprotection"
  • obj of both server and client projects
  • bin of both server and client projects

and then ran a dotnet restore, but it doesn't fix it.

Version 2.0 depends on .net 7.0

I created a new project, tried both 1.9 and 1.8, and in both times I got this error during Publish:

The "BlazorWasmAntivirusProtection.Tasks.CleanOldDlls" task could not be loaded from the assembly C:\Users\user\.nuget\packages\blazorwasmantivirusprotection\1.8.5\build\net6.0....\tasks\BlazorWasmAntivirusProtection.Tasks.dll. Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask

I tried updating to 2.0.0 on my .Net 7 project and am also getting this error on publish, except it says System.Runtime, Version=7.0.0.0.

No issues on 1.8.5.

Severity Code Description Project File Line Suppression State
Error The "BlazorWasmAntivirusProtection.Tasks.CleanOldDlls" task could not be loaded from the assembly C:\Users\xxxx.nuget\packages\blazorwasmantivirusprotection\2.0.0\build\net6.0....\tasks\BlazorWasmAntivirusProtection.Tasks.dll. Could not load file or assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask

@stavroskasidis , I'm also facing the same error.

C:\Users\xxxx.nuget\packages\blazorwasmantivirusprotection\2.0.0\build\net6.0\BlazorWasmAntivirusProtection.targets(19,3): Error MSB4062: The "BlazorWasmAntivirusProtection.Tasks.CleanOldDlls" task could not be loaded from the assembly C:\Users\xxxx.nuget\packages\blazorwasmantivirusprotection\2.0.0\build\net6.0....\tasks\BlazorWasmAntivirusProtection.Tasks.dll. Could not load file or assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

Sample Repo

Thank you for your feedback. I think I see the issue. I will fix it asap and post a new version

Hi,

I still have the same error with the 2.1 version on dotnet 7. Do i need to do something ?

Yes same issue exists with 2.1 version on .net 7 - Sample Repo

I can't reproduce it. I have tried the sample repo you provided, in multiple PCs, everything works. I even tried a clean PC with only sdk 7.0 installed. What does your dotnet --info say? What sdks you have installed? Do you maybe have some .net7 preview sdk installed that interferes?

@stavroskasidis , Here is my dotnet --info command output

.NET SDK:
 Version:   7.0.100
 Commit:    e12b7af219

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.100\

Host:
  Version:      7.0.0
  Architecture: x64
  Commit:       d099f075e4

.NET SDKs installed:
  6.0.201 [C:\Program Files\dotnet\sdk]
  7.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Out of curiosity, I ran "dotnet publish" from the command line and it seems like it works, the bug happens if I attempt to publish (even just direct-to-folder) from Visual Studio 2022 though. I haven't tried to migrate to the new container publishing stuff from .Net 7, so at the moment I publish to docker through VS and Docker Desktop.

Wonder if it's a VS bug trying to find the runtime? I don't even technically have the .Net 7 SDK installed standalone, just as part of the Visual Studio install process.

@Xeio the sample repo I provided above tries to run dotnet publish from command line using GitHub actions and it fails there.

I'm very sorry, it is my fault! The error was caused by pull request #32 from me.

Hi @stavroskasidis , could you take a look at a new pull request #39 to recover from this problem?

@jsakamoto Thank you for finding this. I went a different approach from your PR, I used Brotli.NET which works in .netstandard2.0, a simpler change.

Everyone try using v2.2.1, these issues should now be fixed.

@stavroskasidis

Thank you for finding this. I went a different approach from your PR, I used Brotli.NET which works in .netstandard2.0, a simpler change.

Oh, I took my mistake again, I failed update my development environment to track your latest achievement.
I'm very sorry to bother you.

@stavroskasidis

I noticed there is the message below from @fingers10 :

the sample repo I provided above tries to run dotnet publish from command line using GitHub actions and it fails there.

The problem above is caused by the "BlazorWasmPreRendering.Build" NuGet package, not from your package. So it is good to close this issue with the resolved status.

Yeah also this works when published from command line but fails with visual studio publish

@fingers10

Yeah also this works when published from command line

On my environment, your project is failed with the latest version 2.2.1, regardless of whether command line or Visual Studio. Moreover, the error message tells me the reason for the error is in the "BlazorWasmPreRendering.Build". So please don't post about it to this issue thread anymore. Instead, please post about it to the issue thread of the "BlazorWasmPreRendering.Build" (Issue 22).

Just confirming that 2.2.1 seems to work for me now as far as the issue in the OP (CleanOldDlls task).

@stavroskasidis for some reason the publish fails in github actions deploy. Here is the link.

Error:

The type initializer for 'Brotli.Brolib64' threw an exception

Logs:

/home/runner/.nuget/packages/blazorwasmantivirusprotection/2.2.1/build/net7.0/BlazorWasmAntivirusProtection.targets(36,3): error : The type initializer for 'Brotli.Brolib64' threw an exception. [/home/runner/work/ilovedotnet/ilovedotnet/Web/Web.csproj]
  BlazorWasmAntivirusProtection: Renaming .dll files to .dat finished
Error: Process completed with exit code 1.

Please refer issue for more details.

@jsakamoto Turns out your implementation of packaging a BrotliCompress tool as a console app is a better implementation, because Brotli.NET uses native dependencies that may not be there (e.g. Docker container, github actions agent).

I am releasing a new version (2.3) that includes your code from the pull request you submited earlier.
Thank you for implementing it.

@fingers10 Please try version 2.3.0-beta to see if that fixes the problem.

Closing as it should be fixed with 2.3.0. Please reopen if you still have an issue.