Quantcast
Channel: wixsharp Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1354

New Post: How to add items to the Windows start-menu after the Project constructor?

$
0
0
If you want to put the shortcut to the start-menu and desktop then your code (using constructor) will look need to be like this:
new Dir(@"%ProgramFiles%\My Company\My Product",
         new File(@"AppFiles\MyApp.exe",
                new FileShortcut("MyApp", @"%ProgramMenu%\My Company\My Product"),
                new FileShortcut("MyApp", "%Desktop%")),
         ...
If you want to add shortcuts outside of constructor then you may use initializers:
new Dir(@"%ProgramFiles%\My Company\My Product",
         new File(@"AppFiles\MyApp.exe")
         {
                Shortcuts = new[]
                            {
                                new FileShortcut("MyApp", @"%ProgramMenu%\My Company\My Product"),
                                new FileShortcut("MyApp", "%Desktop%")
                            }
         }
         ...
If you want to add shortcuts completely outside of your project declaration then you can use LINQ as Repete4711 suggested.

You can find the corresponding sample in the "Wix# Samples\AllInOne" folder.
new FileShortcut("MyApp.exe", "%Desktop%")
Does that place a shortcut to MyApp.exe onto the Windows Desktop?
Yes.
How do you control what the text of the shortcut is?
By default the name of the link (shortcut) file is the name of the executable it is associated with but with the new extension '.lnk'
If you want to have different name then you need to adjust it when the WiX is generated. Thus you need to handle source s you need to handle WixSourceGenerated event:
staticvoid Compiler_WixSourceGenerated(XDocument document)
    {
        document.Root.Descendants("Shortcut").ToList()
                     .ForEach(x => 
                      {
                          if(x.Attribute("Name").Value == "MyApp.lnk")
                            x.Attribute("Name").Value = "My Product App.lnk";
                      });
    }
And what informs this statement WHERE that file MyApp.exe is? Does it internally find the file matching that string literal?
'FileShortcut' has parent 'new File("AppFiles\MyApp.exe"...,' who is that MyApp.exe.

Viewing all articles
Browse latest Browse all 1354

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>