6

I'm getting an error that my project can't find a reference. Copy Local is originally set to True, but after rebuilding the solution, it changes back to False:

enter image description here

Why would this happen? How can I make it stick? I tried editing the project itself:

enter image description here

However, the reference shows that Copy Local is still false after a rebuild.

Bob Horn
  • 33,387
  • 34
  • 113
  • 219
  • interesting.. I don't think I ever saw a simple clean/rebuild action modify the project file, you're sure there's no build event or so that for instance tells the versioning system to reset any changes made? Or something else that could be modifying the file? What happens if you make it read-only? – stijn Jan 17 '14 at 19:55
  • The rebuild doesn't modify the project file. `Private` is still `True`. However, when I look at the properties window for the reference, `Copy Local` is set back to false. – Bob Horn Jan 17 '14 at 20:00
  • There is no build event. Why would making the file read-only matter? – Bob Horn Jan 17 '14 at 20:04
  • Because when I read your question the first time I was under the impression the project file changed on disk - now since you clarified it's only it's in-memory representation (what is reflected in the gui), simply ignore my first comment – stijn Jan 17 '14 at 20:06
  • You have the strangest problems. There is a condition where MSBuild overrides CopyLocal, it is a very obscure one. You need to provide better diagnostics. Turn up MSBuild verbosity to Detailed and provide the trace you get in a paste bin. – Hans Passant Jan 18 '14 at 12:05
  • @HansPassant Here is the paste bin: http://pastebin.com/4PwLUYfF. The project with the issue is ConsoleTester. – Bob Horn Jan 20 '14 at 14:21
  • Sigh, it is just a plain "file not found" error message. Remove the assembly reference and add it back. – Hans Passant Jan 20 '14 at 17:58
  • I had actually already tried that a couple times. Keeps happening. – Bob Horn Jan 20 '14 at 19:07
  • See: http://stackoverflow.com/questions/1682096/how-do-i-override-copylocal-private-setting-for-references-in-net-from-msbuil – Michael Haephrati Jun 12 '15 at 21:08

1 Answers1

0

This could caused by registering the Referenced Assembly to the Global Assembly Cache during the build. If the assembly is found in the global assembly cache, the value for Copy Local is set to false.

See answer here: https://stackoverflow.com/a/3101105/1196586

gReX
  • 1,060
  • 1
  • 20
  • 35