Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
calnastic0 opened this issue Nov 10, 2022 · 21 comments

Comments

@calnastic0
Copy link

calnastic0 commented Nov 10, 2022

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.

@stavroskasidis
Copy link
Owner

Version 2.0 depends on .net 7.0

@calnastic0
Copy link
Author

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

@Xeio
Copy link

Xeio commented Nov 14, 2022

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

@fingers10
Copy link

@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

@stavroskasidis
Copy link
Owner

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

@nc-overflow
Copy link

Hi,

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

@fingers10
Copy link

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

@stavroskasidis
Copy link
Owner

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?

@fingers10
Copy link

fingers10 commented Nov 19, 2022

@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

@Xeio
Copy link

Xeio commented Nov 19, 2022

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.

@fingers10
Copy link

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

@jsakamoto
Copy link
Contributor

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?

@stavroskasidis
Copy link
Owner

@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.

@jsakamoto
Copy link
Contributor

@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.

@jsakamoto
Copy link
Contributor

@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.

@fingers10
Copy link

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

@jsakamoto
Copy link
Contributor

@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).

@Xeio
Copy link

Xeio commented Nov 20, 2022

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

@fingers10
Copy link

@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.

@stavroskasidis
Copy link
Owner

stavroskasidis commented Nov 23, 2022

@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.

@stavroskasidis
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants