While debugging one of my customers’ scenarios, we came across an interesting issue were if we ‘rebuild’ the application we get a warning for a missing file, and for the same application when we ‘build’ everything works fine.
All this occurs only in VS2010 and not in the earlier versions of Visual Studio. To understand what went wrong, like anybody would do, the first approach was to use procmon and compare the file creation/deletion activity.
For the purpose of explaining this scenario, I created a sample application, App.exe that depends on a dll, lib.dll . I did make changes to project settings such that both the projects have a common intermediate directory. (Btw, this works fine in VS2005,VS2008 )
Rebuilding the sample I created in VS2010 IDE, I did see that it throws a linker error 2>LINK: fatal error LNK1104: cannot open file '.\abc\Projects\App\Debug\lib.lib'
Again, Building the application, both projects were built successfully and all worked absolutely fine.
Snip from the procmon log when Rebuilding(failing) the application;
This is how the intermediate Directory for both the projects looks;
So the reason for the failure was because of the deleted file. While we have the above snip, it was not obvious in the beginning and took some time for us to come to this point.
The mystery of MSBuild deleting the file in VS2010 but not in earlier versions of Visual Studio was identified to be a design change in VS2010. More specifically, with VS2010, the Intermediate directory cannot be same for all the referenced projects in the solution.
If accidentally, the intermediate directory is same, we will notice a warning/error about missing files depending on the respective project.
The snips I pasted above are only to show the failure and what you can look for when we have such a scenario. The takeaway for us was the “by design” change in VS2010 in which we cannot have same folder for the intermediate directory for projects in the solution. This issue might be prominent when porting from an earlier version of VS to VS2010.
Technical Lead | Microsoft Developer Support | Visual C++, C#, CLR