.NET Framework Bookmark and Share   
 index > MSBuild > Error when invoking MSBuild from command line
 

Error when invoking MSBuild from command line

Hi everyone,

I am invoking MSBuild from command line and am running into the following error:

[INFO] Build FAILED.
[INFO] CSC : error CS0006: Metadata file '..\..\..\..\..\..\dotNetLib\Microsoft.Practices.Enterprise
Library\ExceptionHandling.Logging\2.0.0.0\ExceptionHandling.Logging.dll' could not be found
[INFO] 0 Warning(s)
[INFO] 1 Error(s)

The dll in question DOES exist at the path specified. This error is occuring in the "corecompile" target. Prior to this step, there seems to be another target that's invoked which is "resolveassemblyreferences" and here's the output from that:

[INFO] Target ResolveAssemblyReferences:
[INFO] Primary reference "Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Versi
on=2.0.0.0, Culture=neutral, PublicKeyToken=null".
[INFO] Could not find dependent files. The system cannot find the path specified. (Exception
from HRESULT: 0x80070003)
[INFO] Resolved file path is "..\..\..\..\..\..\dotNetLib\Microsoft.Practices.EnterpriseLibr
ary\ExceptionHandling.Logging\2.0.0.0\ExceptionHandling.Logging.dll".
[INFO] Reference found at search path location "{HintPathFromItem}".

It seems like the resolve assemblyreferences IS able to find the reference in the end so I am not sure why the error is occuring. I've been wrestling with this for over a day and am at my wit's end. Any help will be greatly appreciated.

Thank you.

MSBUser

I am responding to my own post here since I, with the the help of some great team members, was able to find the reason for the issue and wanted to share this knowledge with other poor souls who may be running into the same issue and need to find a fix.

The problem was with the length of the absolute path to the dll. If a certain length (I think 250) is exceeded, the build fails with a vague error about "metadata file..." not being found. So if you shorten the path to your references the problem will go away.

Hope this helps.

MSBUser

I am responding to my own post here since I, with the the help of some great team members, was able to find the reason for the issue and wanted to share this knowledge with other poor souls who may be running into the same issue and need to find a fix.

The problem was with the length of the absolute path to the dll. If a certain length (I think 250) is exceeded, the build fails with a vague error about "metadata file..." not being found. So if you shorten the path to your references the problem will go away.

Hope this helps.

MSBUser
Thanks for posting this.

The fact that we see such an error is more evidence of the general stupidity and lack of care that seems to be taken at MS. If MS did not have a monopoly on desktop OS software we would have much fewer of these stupid issues and much better software in general. I wish I had a penny for every time I come across something like this.... grrrrrrr


mcounsell0
Thank you so much. Without this post I would probably have spent a day as well trying to find the answer.
srferdave
Yes, from what I've read elsewhere, the length of the file path may not be more than 259 characters long. I had a similar problem:

CSC : error CS0006: Metadata file '..\..\..\..\..\..\..\Common Services\Components\Microsoft\EntLib\4.1\BIN\Microsoft.Practices.EnterpriseLibrary.Common.dll' could not be found

In my case, however, the path resolves to:

D:\15\Sources\Common Services\Components\Microsoft\EntLib\4.1\BIN\Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll

which is just 134 characters long (way under the 259 character limit). If I shorten the path, I don't get the error anymore, which leads me to think that, somehow, Windowsresolves the relative path to exceed the 259 character limit.
Igor Pashchuk - RSA
Yes, from what I've read elsewhere, the length of the file path may not be more than 259 characters long. I had a similar problem:

CSC : error CS0006: Metadata file '..\..\..\..\..\..\..\Common Services\Components\Microsoft\EntLib\4.1\BIN\Microsoft.Practices.EnterpriseLibrary.Common.dll' could not be found

In my case, however, the path resolves to:

D:\15\Sources\Common Services\Components\Microsoft\EntLib\4.1\BIN\Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll

which is just 134 characters long (way under the 259 character limit). If I shorten the path, I don't get the error anymore, which leads me to think that, somehow, Windowsresolves the relative path to exceed the 259 character limit.

Windows seems to handle the path just fine (Visual Studio will build the project), however if you look at DOS, it gets upset with the lengths. Drop into a DOS prompt, and navigate to the project directory you're having issues with, and type:

dir ..\..\..\..\..\..\..\Common Services\Components\Microsoft\EntLib\4.1\BIN\Microsoft.Practices.EnterpriseLibrary.Common.dll

And you should get an error about the filename or extension being too long. So is MSBuild seeing the same limitations on path limits as DOS? Quite likely. If you're pressed for time, I found you can simply comment out the HintPath from the project file to get MSBuild to build the project. Project appears to still build without error as it'll fall back to the GAC for the reference.
Jonathan Angliss
Jonathan Angliss

You can use google to search for other answers

Custom Search

More Threads

• Why not tighter integration with things like MSBee????
• Select target framework VSTS2008
• vs2005 website release error
• Any way to convert 2003 solution file to 2005 format
• Easier editing of MSBuild projects in VS 2008?
• Custom properties in PropertyGroup.
• Changing assembly reference path base on configuration
• Summary Of Property Evaluation in MSBuild
• MSBuild not copying over references not used
• How to set envrionment variables in MSBuild file?