views:

592

answers:

5

Does anyone have a method to overcome the 260 character limit of the MSBuild tool for building Visual Studio projects and solutions from the command line? I'm trying to get the build automated using CruiseControl (CruiseControl.NET isn't an option, so I'm trying to tie it into normal ant scripts) and I keep on running into problems with the length of the paths. To clarify, the problem is in the length of paths of projects referenced in the solution file, as the tool doesn't collapse paths down properly :(

I've also tried using DevEnv which sometimes works and sometimes throws an exception, which isn't good for an automated build on a separate machine. So please don't suggest using this as a replacement.

And to top it all, the project builds fine when using Visual Studio through the normal IDE.

A: 

Have you tried DOS paths? Or the \\?\ prefix? The .NET BCL team blog has more info.

Judah Himango
+1  A: 

It seems that it is limitation of the MSBuild. We had the same problem, and in the end, we had to get paths shortened, because did not find any other solution that worked properly.

Nenad
After several days of effort, this seems to be what I'm going to have to request. Thankfully a new (much shorter) path structure is being proposed for these projects, so the problem should go away then :)
workmad3
System.IO of the .Net framework (v1.0-v3.5) has this limitation and MSBuild is using .Net. (Currently the only way around this is using PInvoke about everywhere a path is used.)
Bert Huijben
+4  A: 

The SUBST command stills seems to exist so remapping the root of your build folder to a drive letter may save some characters if Judah Himango's solution is no good.

Jason Stangroome
They are already being SUBST'd to the most common root of the directory structure :( It would work if the path names weren't so infernally long though.
workmad3
We're using subst to build the Silverlight Toolkit, it isn't perfect, but this hack is a good first step. +1 Jason
Jeff Wilcox
+1  A: 

There are two kinds of long path problems relevant to build. One is paths that aren't really too long, but have lots of "..\" in them. Typically, these are references' HintPath values. MSBuild should normalize these paths down to below the max limit, so that they work.

The other kind of path is just plain too long. Sorry, but these just won't work. After looking at it a fair bit, the problem is that there just isn't sufficient API support for long paths. The BCL team (see their blog) had similar problems. Only some of the Win32 API's support the \?\ format. Arbitrary build tools, and probably 98% of apps out there, don't; and worse would probably behave badly (think of all the buffers sized for MAX_PATH).

We came to the conclusion that until there's a big ecosystem effort to make long paths work, or Windows comes up with some ingenious way to make them work anyway (like the short paths mangling?) long paths just aren't possible for MSBuild to support. Workarounds include subst, as you found; but if your tree just is simply too deep, your only options are to build it in fragments, or to shorten the folder names. Sorry.

Dan/MSBuild

dan moseley
A: 

I had recently changed my password when this occurred. I logged out and logged back in and it worked great.

Travis