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:
If you want to add shortcuts outside of constructor then you may use initializers:
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.
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:
new Dir(@"%ProgramFiles%\My Company\My Product", new File(@"AppFiles\MyApp.exe", new FileShortcut("MyApp", @"%ProgramMenu%\My Company\My Product"), new FileShortcut("MyApp", "%Desktop%")), ...
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%") } } ...
You can find the corresponding sample in the "Wix# Samples\AllInOne" folder.
new FileShortcut("MyApp.exe", "%Desktop%")Yes.
Does that place a shortcut to MyApp.exe onto the Windows Desktop?
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.