Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error MSB3027: Could not copy "C:\pagefile.sys" to "bin\roslyn\pagefile.sys". Exceeded retry count of 10. Failed

I am consistently getting this error with VS 2013:

Could not copy "C:\pagefile.sys" to "bin\roslyn\pagefile.sys". Exceeded retry count of 10. Failed. Unable to copy file "C:\pagefile.sys" to "bin\roslyn\pagefile.sys". The process cannot access the file

Please help me.

like image 382
Pramod Raut Avatar asked May 25 '16 05:05

Pramod Raut


5 Answers

As indicated in this answer from Pramod's comment the problem stems from the Microsoft.CodeDom.Providers.DotNetCompilerPlatform nuget package, specifically upgrading from version 1.0.0 to 1.0.1.

For me however, downgrading using Visual Studio caused further build errors. To solve the problem I had to manually edit my csproj and packages.config files, removing all references to Microsoft.Net.Compilers and Microsoft.CodeDom.Providers.DotNetCompilerPlatform.

Specifically, this meant:

  • Removing the relevant <Import Project="... sections for all versions of both libraries (usually towards the beginning of the csproj)
  • Removing the <Reference Include="... sections for both versions of both libraries
  • Removing the <Error Condition="!Exists(... sections for both versions of both libraries from within the EnsureNuGetPackageBuildImports target section
  • Removing all Microsoft.CodeDom.Providers.DotNetCompilerPlatform and Microsoft.Net.Compilers packages from the packages.config.

I was then able to manage the projects nuget packages in VS and (in order) :

  • Add Microsoft.Net.Compilers version 1.2.2
  • Add Microsoft.CodeDom.Providers.DotNetCompilerPlatform version 1.0.1

This solved the pagefile build error, and the runtime error which prompted me to try and upgrade in the first place.

like image 101
T S Taylor Avatar answered Nov 09 '22 18:11

T S Taylor


I removed these packages from nuget package manager since I do not use them:

  • Microsoft.CodeDom.Providers.DotNetCompilerPlatform

  • Microsoft.Net.Compilers

Now everything works.

like image 24
toha Avatar answered Nov 09 '22 18:11

toha


I've found a different solution to this error. In my case I had been moving around a project within my solution (I put it in a subfolder). My references to packages (located in %solutionfolder%/packages) in the project file were broken and I fixed them manually.

However, there are two supplement imports that I forgot:

  <Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
  <Import Project="..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" />

I first updated the first one from ..\packages to ..\..\packages (lazy as I am). Building the project after that gave me the pagefile.sys error.

Updating the second import (same change: ..\packages to ..\..\packages) solved it for me.

like image 4
Willem van Hooijdonk Avatar answered Nov 09 '22 19:11

Willem van Hooijdonk


Using the Clean Solution/Rebuild Solution steps resolved this issue for me.

like image 2
Granicus Avatar answered Nov 09 '22 19:11

Granicus


Remove these two lines from .csproj file:

<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" />
like image 1
osman Avatar answered Nov 09 '22 18:11

osman