Search code examples
wixwindows-installerwix3.5wix3.7wix3.6

MSI APIs does not support long filenames - How to shorten the file name?


I am using Wix to generate MSI

Wix is dynamically generating the ComponentsGenerated.wxs file from the project reference.

One of the DLL in the project is having the longest name as follow

  <Component Id="D5CF013A7A8C3FB9D1BD48B1996555DA" 
             Guid="{CBDB1BC0-F4EE-4824-B937-D9F66278F89A}">
     <File Id="8EDDC3C71F9C124B466555A59378747" 
            KeyPath="yes" Source="$(var.BasePath)\Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.dll" />
   </Component>

Here: var.BasePath = "C:\Work\Projects\WixProjects\InstallerProjects\Client"

Therefore, I was getting file not found an error while I try to build a Wix project.

I have moved my project to C drive. Now: var.BasePath = "C:\Client\"

Error got resolved. But question is, what is the better way to fix it? I do not want to move the project to C drive. there must be a way to shorten the length of the file in wix I believe. if yes, how can I do it?


Solution

  • NTFS Policy: This I have never tried, but in recent versions of Windows 10 (Version 1607 and up apparently - run "winver.exe") there is a new NT / group policy that you can try. The policy is: Enable NTFS long paths.

    Local Drives: Enable the policy (procedure below) and perhaps do a reboot. Then remember to use local NTFS drives - preferring the system drive I'd say. Let us know the results? (just a quick comment?).

    Build Time Only: Seeing as you need these paths to compile and build and not to install, this might work? You need to be careful though, or your package could contain too long paths to install downstream (might not compile, I am not sure). You need very good QA - obviously. I would go back to Windows 7 to be honest - to really test things.

    Description: "Enabling NTFS long paths will allow manifested win32 applications and Windows Store applications to access paths beyond the normal 260 char limit per node."

    Launch Conditions: A generic mechanism to prevent installation on unsupported systems (for whatever reason) is the MSI's launch conditions concept.

    Policy: gpedit.msc: Setting the Group Policy (NB! Only PRO version of Windows I think!):

    1. Press Windows key and tap R, type gpedit.msc and press Enter.
    2. Go to: Local Computer Policy => Computer Configuration => Administrative Templates => System => Filesystem.
    3. Double click the Enable NTFS long paths option. Enable it.

    Disclaimer! Side effects unknown.

    NTFS Policy


    Simplified Markup: One more thing. In a subjective opinion I find WiX markup to be slightly over-complicated for many things. The authors of WiX have taken the toolkit in an interesting direction by allowing auto-generation of "boilerplate attributes" (if that is a term). Please see this answer for more: Syntax for guids in WIX?

    And here is a sample of simplified WiX markup:

    <!-- Sample guid below, do not copy paste -->
    <Component Id="File.dll" Guid="{12345678-1234-1234-1234-123456789ABC}">
      <File Id="File.dll" Name="File.dll" KeyPath="yes" Source="..\File.dll" />
    </Component>
    

    versus

    <Component>
      <File Source="..\File.dll" />
    </Component>
    

    Links: