Domanda

I need to create a symbolic-link for a particular folder; that folder is created by a WIX installer. Is there any way to create a symbolic-link from WIX installer? I have read about mklink, but I do not know how to use that in WIX (v3)?

È stato utile?

Soluzione 2

I had crated a link by using Shortcut keyword. And I found it is the easiest way to resolve this. Please find this code.

<Component Id="XXXX" Guid="E4920A35-13E1-4949-BD3A-7DCC8A70C647">
          <File Id="xxXX" Name="xxXX.yyy" Source="..\Installer\Miscellaneous\xxXX.yyy" DiskId="1" Vital="yes" />
              <Shortcut Id="xxXX_link" Directory="Dir1" Name="xxXX.yyy" Target="[INSTALLLOCATION]xxXX.yyy" WorkingDirectory="INSTALLLOCATION" />
</Component>

But this is not equivalent to symbolic link.

Altri suggerimenti

You can use Custom actions to run the mklink. Run the custom actions after InstallFinalize.

Or you can use Short cut instead of symbolic links.

In Custom Action file:

[CustomAction]
    public static ActionResult symboliclink(Session session)
    {
        string filePath = session["FilePath"];
        string symboliclink = session["symboliclink"];
        Process p = new Process();

        p.StartInfo.FileName = "mklink.exe";
        p.StartInfo.Arguments = "/d" + symboliclink + " " + filePath;
        p.StartInfo.CreateNoWindow = true;
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
        Environment.CurrentDirectory = Path.GetDirectoryName(p.StartInfo.FileName);
        p.Start();
        p.WaitForExit();


        return ActionResult.Success;
    }

Wix File:

<Binary Id="Symboliclink" SourceFile="Symboliclink.CA.dll" />   <CustomAction Id="SymbolicLink" BinaryKey="Symboliclink" DllEntry="symboliclink" Return="ignore" Execute="immediate" />

Include the Custom Action in InstallExecuteSequence

 <Custom Action="SymbolicLink" Sequence="6703"/>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top