MSBuild error “CSC : error CS2001: Source File ‘x’ could not be found” with Linked Files after upgrading to Visual Studio 2012

msbuildvisual studio 2012

After automatically upgrading the project file for a .Net 4.0 web application to work with Visual Studio 2012 everything worked ok at first however when compiling I got lots of errors like this:

Description : Source File '..\..\..\..\..\File Path' could not be found

File : CSC

And when trying to build using MSBuild (passing just the project full path, with no additional parameters) in the "Developer Command Prompt for VS2012" I got basically the same errors:

"CSC : error CS2001: Source File 'x' could not be found"

All errors refer to Linked Files (aspx,cs,etc) located in other web applications projects located at a different deep in our code Branch (that's why all the '….\' at the beginning of the paths)

To me it looks like a problem with the file Length, I had the same problem a while ago when building the projects on our CI server using MSBuild, I was able to manage it by manipulating the project files before building them using a custom script without the need to move the branch around or reduce the deep of the projects, I didn't have to move anything, the important thing at the time it was that developers using Visual Studio 2010 could compile everything without problems. I learned by this that compiling/Building with MSBuild was different that with DevEnv/VS, and for example MSBuild didn't support building Setup projects and DevEnv did.

Since this is happening now with VS 2012/DevEnv 2012 , plus that VS 2012 doesn't support setup projects anymore (like msbuild), plus VS/DevEnv have the same problem with the file length, it looks like VS 2012 its finally using msbuild under the hood or are more tightly integrated, however I didn't find any article to confirm this.

Changing the branch structure/changing the deep of the projects it’s not an option right now due to several reasons (large code base, high number of projects, risk, timing, effort, etc.).

Does someone have an alternative solution or a fix for this issue in Visual Studio 2012?

Regards,

P.D.: BTW I already checked this post MSBuild error with linked files but like I said before changing the paths its not an option right now.

Best Answer

Try getting the Build Logs,

http://msdn.microsoft.com/en-us/library/vstudio/ms171470.aspx

it seems that csc task could not find the source file. One cause it you import the wrong file. so you have to edit the project file via normal Text Editor.