Вопрос

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 ‘..’

:___(

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top