failwyn / WebCompiler

Visual Studio extension for compiling LESS and Sass files
Other
77 stars 16 forks source link

Compilation of less file fails with 7z.dll unhandled exception #30

Open JanVargovsky opened 2 years ago

JanVargovsky commented 2 years ago

Installed product versions

Description

Compiling site.less fails on access to the path 7z.dll

Steps to recreate

  1. Standard ASP.NET .NET 6 project (Blazor server)
  2. have wwwroot/css/site.less
  3. run compilation

Current behavior

Fails on unhandled exception

C:\... repo> C:\USERS\... path to VS\WebCompiler.exe "C:/.../compilerconfig.json" "wwwroot/css/site.less"

Unhandled Exception: System.UnauthorizedAccessException: Access to the path '7z.dll' is denied.
   at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive, Boolean throwOnTopLevelDirectoryNotFound, WIN32_FIND_DATA& data)
   at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
   at WebCompiler.CompilerService.Initialize() in W:\Git\Light Speed Solutions\WebCompiler\src\WebCompiler\Compile\CompilerService.cs:line 93
   at WebCompiler.CompilerService.GetCompiler(Config config) in W:\Git\Light Speed Solutions\WebCompiler\src\WebCompiler\Compile\CompilerService.cs:line 37
   at WebCompiler.ConfigFileProcessor.ProcessConfig(String baseFolder, Config config) in W:\Git\Light Speed Solutions\WebCompiler\src\WebCompiler\Config\ConfigFileProcessor.cs:line 190
   at WebCompiler.ConfigFileProcessor.Process(String configFile, IEnumerable`1 configs, Boolean force) in W:\Git\Light Speed Solutions\WebCompiler\src\WebCompiler\Config\ConfigFileProcessor.cs:line 44
   at WebCompiler.Program.Main(String[] args) in W:\Git\Light Speed Solutions\WebCompiler\src\WebCompiler\Program.cs:line 25
Process terminated with code -532462766.

Expected behavior

The file should be compiled/bundled with no exception or at least with meaningful information why is it trying to delete the 7z.dll.

failwyn commented 2 years ago

Can you try the fix outlined here?

Quote from @mgandley

I've had this same problem a few times, and it was very painful to track down and fix each time. So, here's my write-up on how I fixed it - hopefully it saves some of you some time.

Problem: Seemingly out of the blue, the Web Compiler stops working. It throws an error of "Access to the path 7z.dll is denied." In my case, I had been using it to compile SCSS files successfully for months.

Fix:

Exit Visual Studio entirely. Open C:\Users\%username%\AppData\Local\Temp Find the WebCompiler subfolder for your version and delete it Reopen Visual Studio. This should recreate the WebCompiler subfolder. Open the WebCompiler subfolder (backup this folder before you run prepare.cmd) Execute the prepare.cmd batch script and prepare to wait for 10 minutes while it unzips a full node_modules directory. Once this is done, you should be all set. Try saving a file. If this fixes it for you, please (1) comment and (2) let us know if you ended up having a compilation error in one of your files that may have caused the root problem. I personally did (an rgba attribute with no alpha supplied, ala rgba(10,10,10)).

Frustrating red herrings:

The folder contains a console version of 7 zip, but the task runner may not have permissions to execute in your local user task directory. This might be the source of the failure. The prepare.cmd batch file deletes itself, the 7z.exe, and the node_modules.7z files once it completes, making it way harder to figure out what is happening. If it deletes these without succeeding you're up a creek until you clear out the temp folder.

JanVargovsky commented 2 years ago

Well, I've set it to uninstall with next VS close, then ignored it, so it was still installed, and was trying to find other extension and in the meantime, it started working.

failwyn commented 2 years ago

It seams like it's a very rare issue based on the number of comments over the last 3 years (on the initial issue in Mads' repo); let me know if it happens to you again, If we can identify a way to reliably reproduce it, I could probably fix it.

Velociraptor45 commented 1 year ago

I just ran into the same issue, it stopped working from one rebuild to the other. But for me, it was the 7z.exe it couldn't access. I had to execute only the first 4 steps of your instructions to get it working again:

  1. Exit Visual Studio entirely.
  2. Open C:\Users%username%\AppData\Local\Temp
  3. Find the WebCompiler subfolder for your version and delete it
  4. Reopen Visual Studio. This should recreate the WebCompiler subfolder.

Interestingly, when I removed the subfolder, it contained only the 7z.exe. Now after it is fixed, there's a node_modules folder, log.txt & node.exe.