Reputation:
I am using Visual Studio 2005, .NET 2.0
I am not really sure yet under what circumstances it happens, but here is the scenario: I have a solution with a project structure like this: A library project Foo, a library project Bar which references Foo, and a library project Quux which references Foo and Bar.
Compiling fails with the Error message "Metadata file 'Foo.dll' could not be found" from Bar, and "Metadata file 'Foo.dll' could not be found" and "Metadata file 'Bar.dll' could not be found" from Quux.
Looking in my target directory (I have a combined target directory for all 3 projects), it is empty, so no project at all is compiled. Now I can get that Bar and Quux fail if there is no output from Foo. Problem is: Why does Foo silently fail? There is no error from it, and just building Foo instead of the entire solution works fine.
The "funny" thing is, after just pushing the build button again, the Foo.dll file appears, Bar no longer complains but does not produce any output file either, and Quux complains about missing Bar.dll. Pushing the button again, the Bar.dll appears, there are no more errors but no Quux.dll. Only after pushing the button yet again, the Quux.dll appears, once again with no errors.
The project dependencies are all set correctly, the solution build order says exactly the right thing.
I have even tried creating a new solution and new project files, then adding the sources again to those. No joy, either. Same thing happens.
I am completely stumped. Does anyone know a way out of this mess?
Upvotes: 3
Views: 9050
Reputation: 1873
I agree that each project should have its own target directory. I have tried to get cute with this and it always causes more trouble than whatever I was trying to get around.
I have a vs19 , 5 project solution. I just added a new console app. THis app started suddenly compiling without complaint but did not produce files. the unit test project that depends on it complained.
I did the usual
faced w/ the prospect of just creating a new project, i decided to try one other thing
i was left with pretty much a main() that returned a 0 this compiled and produced files
at the end of this exercise things worked.
I can not tell you what changed. Thought I would offer this as a trouble shooting method.
Upvotes: 0
Reputation: 82
For reasons unknown, this happened to me with Visual Studio 2013 in the middle of a morning's work. One build, it was updating the dll, the next, it just wasn't, even though the build seemed to go smoothly. I finally addressed it by deleting the existing dll. With no pre-existing dll, the build had to provide a new one.
Upvotes: 0
Reputation: 1
Drag your project file into note pad and Find with "Import" tag and replace that tag with this
Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"
Its should work
Upvotes: 0
Reputation: 1171
I think a work around to your problem could be using post build events that deletes previous version of your dlls and copies the new ones to your combined target directory.
When you set up the three projects to work this way, you will find that you are compiling each project to it's correspondent bin folder and to a combined target directory. There is a second thing you should do if you decide to work with this, set up for each project in your solution a reference path pointing to the combined target directory. Compiling order must still exist.
This way each project dll will be found in the combined target directory, each time you compile.
Although, this solution has it's own problems such as when a post-build event forgets to wrok properly; but it's rare.
Hope this helps
Upvotes: 1
Reputation: 2982
You should have separate output directory for each project. Each time a project builds, it clears the output directory, so it won't find any dependencies on the next one.
Don't fear losing any DLLs, they'll be copied on each bin directory where they are needed.
Upvotes: 4
Reputation: 38525
Check you build order so that all seems right there.. Try to run a clean solution and build again is this when it happens?
Upvotes: 0
Reputation: 170509
The problem is build order. If some project depends on another then that second project must be built first. Use build dependencies in the solution properties to overcome this.
Upvotes: 0