Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

Compilation Fails because file cannot be copied from obj to bin (MSB3021)

$
0
0

I am using SharpDevelop 4.3.3 (Build 9663) on Windows 7 64 Bits for developing with C# for .NET 4.0 and build error MSB3021 is gradually driving me crazy.

I am working on a solution (or rather, several overlapping (in terms of included projects) solutions) with some 20 or more projects that heavily depend on each other. (Obviously not circularly, but it's not unusual for those projects to have up to 10 references to other projects in the solution.)


In each of those solutions, every now and then I cannot compile certain assemblies any more because the build system claims it cannot copy obj\Debug\<filename>.dll to bin\Debug\<filename>.dll. This has (seemingly with increasing frequency as the code grows) temporarily stopped me many times over the past few months and I have so far been unable to intentionally reproduce the problem whenever I tried.

Therefore, I can only report the following observations:

  • The problem seems to occur primarily in assemblies that are somewhere deeply nested in the dependency graph (i.e. never in the startup project).
  • Rebuilding/Cleaning the projects/solution does not solve the problem.
  • Deleting the files in the output folder manually, if that works, does not solve the problem.
  • Deleting the output folder manually does not solve the problem.
  • Running SharpDevelop with administrator priviledges does not solve the problem.
  • Switching the project to compile as Release instead of Debug (this idea was based on the information provided in this StackOverflow thread) sometimes solves the problem completely; sometimes the problem disappears for the assembly in question and instead the same error is reported for one or even two other assemblies (for which switching to Relase mode doesn't change anything).
  • Switching the whole solution to Release mode usually solves the problem.
  • Switching back to Debug mode (either the project or the solution, depending on which of the aforementioned cases was present) immediately makes the problem reappear exactly as it was before switching to Release mode.
  • Switching back to Debug mode at some later time after some more changes have been made does not make the problem reappear and building works flawlessly.
  • Closing SharpDevelop, opening the solution in Visual Studio 2010, building there, closing Visual Studio, reopening the solution in SharpDevelop and building there usually solves the problem (today was the very first time ever even didn't work any more).
  • SharpDevelop needs to be closed before building from Visual Studio; otherwise VS cannot access the binary files itself.
  • The problem has so far always come back at some point after some days of programming and repeated flawless building.
  • Building only a part of the solution (by building a project that is not the startup project and that does not depend upon every other project) including the files for which the problem was reported usually works, but building the full solution/the startup project makes the errors reappear as they were.
  • When the MSB3021 error occurs, building of the last few projects before the build reports back as failed seems to progress very slowly (as judged by the little progress indicator in the status bar).

I am sorry for not providing anything more structured, but I am close to believing I'm seeing ghosts there. The symptoms really seem that random and unforeseeable. I think however that this is indeed an issue that could be fixed in SharpDevelop rather than just an MSBuild bug because VS seems to cope with it, after all.

I have found a variety of threads in this forum that seem to describe something very similar, if not the same issue:

Those threads indicate that the described bug is supposed to have been fixed in SharpDevelop 2, but that was 7 years ago and I see this MSB3021 issue very much alive and kicking on the latest stable #dev version here and now in 2013. Does anyone know what has happened? Has the fix accidentally been reverted? Does anyone else suffer from the same problem at all (and possibly found any workaround other than constantly closing SharpDevelop and building in VS)?

Thanks in advance


Viewing all articles
Browse latest Browse all 1764

Trending Articles