John S
John S

Reputation: 8351

Visual Studio 2017 bin\roslyn files locked during build

I am running VS2017 version 26430.13 and every time I try to build a web project I get errors that access to the files in the bin\roslyn is denied. Over a period of about 5 minutes the files are unlocked and I can build but the 5 minute delay is unacceptable.

These are the files that stay locked:

Upvotes: 67

Views: 33856

Answers (16)

Younis Qadir
Younis Qadir

Reputation: 435

Deleting this dll Microsoft.CodeDom.Providers.DotNetCompilerPlatform solved the issue for me

Upvotes: 1

moto_geek
moto_geek

Reputation: 580

In VS2017 & VS2019, this can happen when IIS Express is still running. Open the tray next to the clock, hover over the IIS Express icon running, right-click on the icon, click "Exit", confirm prompt, close active running worker processes. This can also be true when trying to publish your web project as well.

Upvotes: 1

I was having the same issue in MVC 5. I just opened Nuget Package Manager, searched and updated the following:

Microsoft.CodeDom.Providers.DotNetCompilerPlatform

Upvotes: 0

Imran Ahmad Shahid
Imran Ahmad Shahid

Reputation: 822

For me I just open solution in file explorer and delete bin folders of all projects in it. now it's working fine.

Upvotes: 1

JGilmartin
JGilmartin

Reputation: 9298

for me updating the nuget package...

Microsoft.Net.Compilers

to the latest at the time of this post 2.7.0 fixed this for me. it was version 1.3.2

Upvotes: 1

Newred
Newred

Reputation: 729

Project > Manage NuGet Packages... > Installed(tab) > in search input set this:

codedom

click to update enter image description here

Upvotes: 7

Ruan
Ruan

Reputation: 4293

Before you try anything drastic, restart your computer

Upvotes: 0

hossein
hossein

Reputation: 1

In my case I did these two steps:

  1. uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
  2. Install-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -Version 1.0.8

Upvotes: 0

TheDude
TheDude

Reputation: 267

Install Microsoft.CodeDom.Providers.DotNetCompilerPlatform.BinFix nuget It fixed the issue for me

Upvotes: 1

sansalk
sansalk

Reputation: 4761

UPDATE the Microsoft.CodeDom.Providers.DotNetCompilerPlatform package to V1.0.7

  • Find Microsoft.CodeDom.Providers.DotNetCompilerPlatform from NuGet Uninstall Old version
    Install V1.0.7 or latest

Upvotes: 79

Usman
Usman

Reputation: 2577

I have VS 2017 Enterprise and for me the issue was resolved by this:

  1. Downgraded Microsoft.Net.Compilers from 2.3.1 to 2.3.0
  2. Downgraded Microsoft.CodeDom.Providers.DotNetCompilerPlatform from 1.0.5 to 1.0.4.

Upvotes: 3

Rob Hoffmann
Rob Hoffmann

Reputation: 1

Update the Microsoft.CodeDom.Providers.DotNetCompilerPlatform package to V1.0.6

Upvotes: -2

threadster
threadster

Reputation: 418

Revert the Microsoft.CodeDom.Providers.DotNetCompilerPlatform package to V1.0.4

This advice came from a comment on the developer community problem report https://developercommunity.visualstudio.com/solutions/79954/view.html.

We were on v1.0.5 and experienced locked files frequently. After reverting the Microsoft.CodeDom.Providers.DotNetCompilerPlatform package to V1.0.4 we are no longer experiencing locked files.

Upvotes: 10

Mircea Matei
Mircea Matei

Reputation: 601

Instead of killing the process manually, you may use the following commands in a Pre-Build Event:

tasklist /FI "IMAGENAME eq VBCSCompiler.exe" 2>NUL | find /I /N "VBCSCompiler.exe">NUL
if "%ERRORLEVEL%"=="0" (taskkill /IM VBCSCompiler.exe /F) else (verify >NUL)

Upvotes: 14

Dean Swiatek
Dean Swiatek

Reputation: 1567

Just open task manager and kill any instances of VBCSCompiler.exe. You don't even need to close Visual Studio.

Upvotes: 142

andrew pate
andrew pate

Reputation: 4297

A workaround is close VS, open task manager and kill any instances of VBCSCompiler.exe

(Thanks Tom John: https://developercommunity.visualstudio.com/content/problem/71302/binroslyn-files-locked-during-build.html)

Upvotes: 10

Related Questions