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

Create/update bundles fails with System.UnauthorizedAccessException #22

Open
amilo2003 opened this issue May 16, 2023 · 4 comments
Open

Comments

@amilo2003
Copy link

Installed product versions

  • Visual Studio: 2022 17.5.5
  • This extension: 2.9.9

Description

Creating a new bundle fails when the solution is bound to source control, in this case Azure Devops.

Steps to recreate

  1. Select 2 .js files
  2. Right click, Bundle and minify files

Current behavior

Creating a new bundle fails with dialog message below when the solution is bound to source control, in this case Azure Devops.

Microsoft Visual Studio

Access to the path 'D:\Visual Studio\Test\Project\bundleconfig.json' is denied.

OK

If a .min file already exists, the .min file is automatically checked out, but bundleconfig.json is not automatically checked out.

If bundleconfig.json is checked out, creating a new bundle fails although the entries are created in bundleconfig.json. The target bundle is not created unless ALL bundles in bundleconfig.json are checked out for editing, even nothing when changed. Error message:

System.UnauthorizedAccessException: Access to the path 'D:\Visual Studio\Test\Project\wwwroot\js\custom-validation.min.js' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.IO.File.OpenFile(String path, FileAccess access, SafeFileHandle& handle)
at System.IO.File.SetLastWriteTimeUtc(String path, DateTime lastWriteTimeUtc)
at BundlerMinifier.BundleFileProcessor.ProcessBundle(String baseFolder, Bundle bundle) in W:\Git\Light Speed Solutions\BundlerMinifier\src\BundlerMinifier.Core\Bundle\BundleFileProcessor.cs:line 140
at BundlerMinifier.BundleFileProcessor.Process(String fileName, IEnumerable`1 bundles) in W:\Git\Light Speed Solutions\BundlerMinifier\src\BundlerMinifier.Core\Bundle\BundleFileProcessor.cs:line 40
at BundlerMinifierVsix.BundleService.<>c__DisplayClass8_0.b__0(Object o) in W:\Git\Light Speed Solutions\BundlerMinifier\src\BundlerMinifierVsix\BundleService.cs:line 112

Expected behavior

Necessary bundled files should be checked out automatically.

@failwyn
Copy link
Owner

failwyn commented May 31, 2023

I don't use Azure DevOps, but it looks like your machine or source control has the files locked so that they cannot be edited. There's no way the Extension can bypass a System.UnauthorizedAccessException, can you try checking out all the required files before running the extension?

@amilo2003
Copy link
Author

amilo2003 commented May 31, 2023 via email

@failwyn
Copy link
Owner

failwyn commented May 31, 2023

There's only one bundleconfig.js file and when that file is modified, all of the bundles defined in it are updated. I just don't have any experience with Azure DevOps, so I don't know if it keeps all files locked until checkout, but the file could just be locked by another process; can you try doing a full reboot, opening Visual Studio, right click bundleconfig.json, select Bundler & Minifier -> Update Bundles and see if it works?

@amilo2003
Copy link
Author

amilo2003 commented Jun 1, 2023 via email

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

2 participants