madskristensen / BundlerMinifier

Visual Studio extension
Other
616 stars 172 forks source link

Minification errors - bundleconfig.json and 'cannot access the file' #113

Open clabough opened 8 years ago

clabough commented 8 years ago

Installed product versions

I'm getting sporadic errors when bundling and minifying. The two errors are 1) "There is an error in the bundleconfig.json file. This could be due to a change in the format after this extension was updated." and the other error is 2) "(Minifier) The process cannot access the file 'C:\project files\project\app\project-bundle.js' because it is being used by another process."

Here's the section of the bundleconfig.json for that:

{ "outputFileName": "App/project-bundle.js", "inputFiles": [ "App/project.module.js", "App/project.controller.js" ] }

Those js files are created from corresponding TypeScript files.

I noticed that error 2 goes away temporarily after I get error 1.

Current behavior

Displaying errors

Expected behavior

No errors. :)

highdownts commented 8 years ago

I am getting the same type of errors running the same version of Visual Studio. I have noticed that when I clean and rebuild the solution, the error happens all the time. If I rebuild the project a second time then the error goes away.

I am using Typescript and generating JavaScript files. When I update a Typescript file and recompile, the error intermittently occurs. When I recompile a second time, the error goes away.

The issue appears to be a race condition between VS and the bundler & minifier.

Update

I did more testing and opened an issue on Stack Overflow at: http://stackoverflow.com/questions/37220177/visual-studio-2015-bundler-minifier-issues-in-web-spa-project

To address the issue near term, I downloaded the Microsoft Ajax Minifier. I am using this successfully in a post build batch file to bundle and minify the project JavaScript code. I am still hoping to get a solution for this issue so that I do not have to run two different bundlers/minifiers since the Ajax Minifier does not handle HTML files.

krispenner commented 8 years ago

I too get the same errors with the exact same setup/scenario noted above.

gerardqueralt commented 8 years ago

In our project, We also have this problem. Anybody knows, if in the future will be fixed? Or We have to change to another tool?

kcodd commented 7 years ago

What about this issue? Will it be fixed?

vdachev commented 7 years ago

I am experiencing the same issue here (in an ASP.NET MVC Core projecton Visual Studio 2015 Update 2) and it sounds like a file locking issue. In fact, my JavaScript files are compiled from TypeScript and I suppose that the Bundler & Minifier task tries to create the bundle while the TypeScript compiler is still working.

kkelvekar commented 7 years ago

Checkout bundle.config file manually using VS. To do so right click on bundle.config file in VS and click on "CheckOut" option. Once file gets checkout then try to change something in JS file which is configure in bundle.config. It will automatically gets minified and checkout.