33

I get this error when building an MVC project in a solution. No references to those files exists in my solution at all.

C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4105,5): error MSB3030: Could not copy the file "D:\bootmgr" because it was not found.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4105,5): error MSB3030: Could not copy the file "D:\BOOTNXT" because it was not found.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4105,5): error MSB3030: Could not copy the file "D:\pagefile.sys" because it was not found.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4105,5): error MSB3030: Could not copy the file "D:\swapfile.sys" because it was not found.

My colleague can build with no errors.

Luke Girvin
  • 13,221
  • 9
  • 64
  • 84
Addeladde
  • 777
  • 2
  • 9
  • 28
  • 1
    You troubleshoot these kind of mishaps by looking at a detailed build trace. Can't help you when you don't show us. – Hans Passant Sep 11 '15 at 14:41
  • Any answer on this would be helpful. I get the following error: Error 12 Could not copy "C:\hiberfil.sys" to "bin\roslyn\hiberfil.sys". Exceeded retry count of 10. Failed. ModellerWebTrials – Thulani Chivandikwa Sep 22 '15 at 07:07
  • 1
    Microsoft.CodeDom.Providers.DotNetCompilerPlatform is a nuget package that is causing this error. – Addeladde Sep 23 '15 at 18:42

8 Answers8

51

I encountered the same issue.

The problem starts when you upgrade the DotNetCompilerPlatform to version 1.0.1.

To work around this issue you can downgrade to version 1.0.0 using the NuGet package manager.

EDIT: If you uninstall Microsoft.CodeDom.Providers.DotNetCompilerPlatform AND Microsoft.Net.Compilers, and then install the DotNetCompilerPlatform (has a dependency on the Microsoft.Net.Compilers package so it will automatically install that) package again the error disappears for good so it seems.

Still not sure what happens under water but I can work again!

Martijn Kooij
  • 1,360
  • 13
  • 23
  • This happens because you have set NuGet to Options / Dependency Behavior to "Ignore Dependencies", so the Microsoft.Net.Compilers were never installed. –  Feb 24 '16 at 09:40
  • 1
    I donot know why Package Manager Console didnot worked for me. I right clicked on my project.. then clicked Manage NuGet Package.. then installed Microsoft.Net.Compilers version 1.2.1 and then Microsoft.CodeDom.Providers.DotNetCompilerPlatform version1.0.0 and then my project build good – Ziggler Apr 30 '16 at 00:01
  • updating to 1.0.3 fixed the issue – balbelias Feb 13 '17 at 14:17
  • I had the same error (Could not copy swapfile.sys / hilberfil.sys) but no compilation errors. Installing "Microsoft.Net.Compilers" solved the problem. I found it very strange that a missing NuGet-Package, which wasn't indicated anywhere has been the issue. It contributes to my impression that NuGet is pretty strange. – Jens Mander May 25 '18 at 12:43
  • 1
    Seems like this issue is very old and I've faced it only now. Using Visual Studio 2017 (15.7.4). Tried to publish MVC web project, which was failing with aforementioned issue. DotNetCompilerPlatform version was 1.0.8 After update to 2.0.0 publishing started working as expected. SO I'd say there is no need to install package version 1.0.0. You can pick the lates available (2.0.0 at the moment) and publish happily with it. – Anatolyevich Jun 19 '18 at 16:58
  • +1 these steps worked for me (remove both, then install DotNetCompilerPlatform 1.0.0 alone). Thank you, sir. – Christopher Nov 05 '19 at 15:23
7

I had the exact same problem. I didn't upgrade DotNetCompilerPlatform to 1.0.1.

My solution was...

  • Exit visual studio
  • Delete your solution's "packages" folder
  • Relaunch VS. The NuGet package manager console window will prompt to restore packages. Do it.
  • Build your solution
Toby Speight
  • 27,591
  • 48
  • 66
  • 103
Greg Woods
  • 2,697
  • 2
  • 26
  • 18
2

I used to have the same issue but I just removed Microsoft.CodeDom.Providers.DotNetCompilerPlatform and then installed 1.0.0. I found that after that it all looks good.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
kG_83
  • 61
  • 4
1

As other's have mentioned it's the upgrade from version 1.0.0 to 1.0.1 of Microsoft.CodeDom.Providers.DotNetCompilerPlatform that causes this problem.

It's possible to solve this without downgrading, see my explanation in this answer. To summarise, what solved it for me was removing all references to the offending libraries manually (simply removing them in VS was not enough) and then re-adding the latest versions.

On further investigation this appears to be due to the 1.0.1 nuget package not clearing up all of the references to 1.0.0 in the csproj. Why this is causing it try and copy the pagefile however is anyone's guess.

Community
  • 1
  • 1
T S Taylor
  • 1,501
  • 1
  • 14
  • 16
0

I have fixed the problem by upgrading 'Mocrosoft.Net.Compilers' to 2.6.1.

enter image description here

Devs love ZenUML
  • 11,344
  • 8
  • 53
  • 67
0

Just uninstalling Microsoft.CodeDom.Providers.DotNetCompilerPlatform from one of our projects fixed this issue for me in Visual Studio 2017.

JDTLH9
  • 1,765
  • 1
  • 23
  • 34
0

Having VS 2015 14.0.25431.01 Update 3, without Xamarin, neither DotNetCompilerPlatform nuget package, and having more build configurations (eg. Debug and RCDebug), i get the unexpected copy which would be coming from another build (eg. copy corresponding to RCDebug but i Rebuild on Debug). It did not worked by deleting all the Bin folders, or Clean on every build config then Build. It builds fine BUT turns bad when Run.

artcoding
  • 1
  • 2
0

Only solution that worked for me was the answer by @Greg Woods. That is, delete the packages folder(preferably rename first to packages.old) and restore the packages

(Previously, messed around with the .csproj file, and manually changed packaged version numbers...and this could have been the cause!)

Tools->NuGet Package Manager->Manage NuGet Packages for Solution, then click restore

Rebuild the solution.

(PS. no reference to Microsoft.CodeDom.Providers.DotNetCompilerPlatform in my solution)

Coder Dev
  • 113
  • 2
  • 9