dotnet / dotnet/wpf

MSBuilds fail from BC2012 error.. Can't open file for writing: Access to the path … is denied.

Open
#1,482 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

VSF_TYPE_MARKDOWNI’ve put up with this error for over a year now because I couldn’t fix it but I could work around it. However, now that the error is happening on the Build Server it is essential that I get a remedy. There are a lot of discussions on the forums about this, including mine. None of the recommended solutions have worked for me.

What happens is that when I run a clean-and-build or a rebuild the error happens. However, a subsequent build will work. That’s how I worked around it all that time; I just pressed Ctrl-Shift-B over and over until all the offending errors went away. I can’t do that repetitive build scheme on the build server, so this needs to be addressed.

It only happens with projects that contain xaml files, but not all projects that contain xaml files are affected. It may be due to the first pass of the markup compiler locking the DLL such that the second pass can’t unlock it. There seems to be a correspondence between projects that produce a [[name]_[random]_wpftmp.[proj]](https://developercommunity.visualstudio.com/content/problem/210156/msbuild-is-adding-a-random-hash-and-wpftmp-to-my-a.html) file. It happens in both VS 2017 and VS 2019. I attached a simple single project solution that will reproduce it; just do a **re**build each time. Additionally, the diagnostic build log is attached.

Mark

_This issue has been moved from https://developercommunity.visualstudio.com/content/problem/549296/msbuiilds-fail-from-bc2012-error-cant-open-file-fo.html
VSTS ticketId: 857501_
_These are the original issue comments:_

Visual Studio Feedback System on 4/28/2019, 01:51 AM (93 days ago):

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

_These are the original issue solutions:_
(no solutions)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.