2

I'm developing a project in WinForms, and I'm on the process of creating an installer using WiX.

But when the installer is going to copy a .dll that comes from a really long path, Visual Studio says this:

'Really long route'\EnterpriseLibrary....\ is too long, the fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

I found articles that talks about MAX_PATH limitations like said in this StackOverflow question related with the Windows API.

I'm working on a big team, and we just discovered this known error, but we are not allowed to shorten or modify the path.

I tried the solution that the link above says, using the \\?\ characters before, so my WixVariables remain like this:

<?define examplesPath="\\?\$(sys.CURRENTDIR)\..\..\ExamplesFolder" ?>

That results to be something like this:

\\?\C:\reallylongpath\files

But it doesn't seem to work for WiX variables.

So my question is:

Is there any way to avoid this 260 characters limitation? If so, how?

Please, I need an answer on this!

EDIT: While I try @Jans' suggestion, I also found that, if I add the \\?\ string to my WiX variable, the error message changes. Now it says:

The system cannot find the file '\\?\Reallylongpath\..\..\andreallylongfile\'

I'm thinking that maybe the \\?\ is not converting the ..\ that I need to use... Any suggestion here?

EDIT2: I found this line at msdn:

A consequence is that \\?\ turns off file name normalization performed by Windows APIs, including removing trailing spaces, expanding ‘.’ and ‘..’

:___(

Community
  • 1
  • 1
Sonhja
  • 8,230
  • 20
  • 73
  • 131
  • See this answer on the question you linked to: http://stackoverflow.com/a/14307022/12971 – Greg May 14 '13 at 15:35
  • I'm taking a look at it, but I'm not sure yet to use an external library to solve the problem. Anyway, I'm gonna try that solution. As written, seems to solve the problem... – Sonhja May 14 '13 at 15:43
  • Ok, this solution is not actually working for me, as I'm trying to use that path in a variable that `WiX`(Windows Installer XML) knows how to interpret. – Sonhja May 14 '13 at 15:46
  • Ah, WiX complicates things – Greg May 14 '13 at 15:46
  • Sure!! I think the same :P – Sonhja May 14 '13 at 15:48
  • It gets worse. The MSI API doesn't support the long paths. So while you can get many of the Win32 APIs to handle long paths correctly, when it comes down to actually getting the MSI built the MSI API paths will start failing. – Rob Mensching May 14 '13 at 16:03
  • :OO Damn! Any suggestion on how can I install a `.dll` using WiX located in a really long path to my machine? – Sonhja May 14 '13 at 16:05
  • Maybe some mixture with `symlinks` as @Jan Doerrenhaus suggested? – Sonhja May 14 '13 at 16:05
  • can you try converting a long path to short path and then try to use that path in wix instead? http://stackoverflow.com/questions/10227144/convert-long-filename-to-short-filename-using-cmd-exe – Syed Ali May 15 '13 at 12:54

1 Answers1

0

This is a terrible hack, but you could create a symlink to the real directory. A symlink is like a regular link, except for that it behaves exactly like a real directory.

Suppose you have a really long directory that causes you trouble:

C:\blahblahblah\thisisreallylong\andnotaccessible\blahblahblah\

You can create a symlink to it, that has any name you like, but is considerably shorter. Think of it as an alias. So if you call this on your console, for example in the C:\temp directory:

C:\temp\>mklink /D reallylong C:\blahblahblah\thisisreallylong\andnotaccessible\blahblahblah\

then afterwards, you can access C:\temp\reallylong as if it were your real directory. Note that you need local admin rights to create symlinks.

Jan Dörrenhaus
  • 6,581
  • 2
  • 34
  • 45
  • Sorry @Jan Doerrenhaus, but I don't seem to be familiar with what you're commenting. Could you please explain a little bit more how to create that symlink? – Sonhja May 14 '13 at 15:42
  • I clarified a little. Is there anything specific you do not understand? – Jan Dörrenhaus May 14 '13 at 15:46
  • No, thanks Jan, I understand your answer. Really clear now :) But my problem comes with `WiX variables`. I need the route to be in a string, to allow WiX to interpret it, so I'm not sure if I can do this using WiX variables... – Sonhja May 14 '13 at 15:47
  • The problem is that the path in your WiX variable is too long, right? So just shorten the path by creating a short symlink pointing to the long path. Then use that symlink inside your WiX variable. – Jan Dörrenhaus May 14 '13 at 15:49
  • Sorry if I don't answer. I'm trying to find how to create symlinks on WiX. I'm trying. – Sonhja May 14 '13 at 15:56