-
Notifications
You must be signed in to change notification settings - Fork 178
VS2019 – 2022 Templates
Wix# comes with various VS2019/2022 project/item templates. They are all packed into Visual Studio Extension - WixSharp Project Templates, which can be downloaded from the Visual Studio Gallery or directly installed from the VS Extension manager.
The extension includes 5 project templates and one item template (Custom UI Dialog).
Note, while VS templates allows embedding NuGet package configuration this feature has been reported as causing major headache for some Wix# users. The automatic package restoring happens to be fragile and it may not work reliably in some Visual Studio environments.
Thus the package information has been removed (at least for now) from the all project templates and the user is required to add the package manually after creating the project from the template:
WiX Toolset installation
Wix# does require WiX binaries (compilers, linkers etc.). Wix# is capable of automatically finding WiX tools only if WiX Toolset installed. In all other cases, you need to set the environment variable WIXSHARP_WIXDIR
or WixSharp.Compiler.WixLocation
to the valid path to the WiX binaries.
WiX binaries can be brought to the built environment by either installing WiX Toolset, downloading Wix# suite or by adding WixSharp.wix.bin
NuGet package to your project. For bringing WiX Tools from NuGet use Install-Package WixSharp.wix.bin
command.
It is important to understand what is involved in building the MSI as otherwise it may be quite uneasy to troubleshoot the integration problems associated with the use of NuGet,VS and MSBuild.
Every Wix# VS project is a C# project that defines building an exe. This exe is an "MSI builder", which if executed uses WiX compilers to produce the final msi.
Thus if you just create manually a simple ConsoleApp project with the Wix# code (as below) and compile it it will build an exe but not msi.
class Script
{
static public void Main()
{
var project = new Project("CustomActionTest",
new ManagedAction("MyAction", Return.check,
When.After, Step.InstallInitialize,
Condition.NOT_Installed));
project.BuildMsi();
}
}
public class CustomActions
{
[CustomAction]
public static ActionResult MyAction(Session session)
{
MessageBox.Show("Hello World!");
return ActionResult.Success;
}
}
However if you run the produced exe (e.g. F5) it in turn will build the desired msi. Instead of running the exe manually every time you can automate it by setting the project post-build event:
All Wx# VS samples are composed this way.
Note, you don't have to set up post-build event manually if you use WixSharp
Nuget package with Visual Studio. The package installation script does it automatically for you. All proper Wix# Visual Studio project templates also come with the post-build exe execution already scheduled. Though not via the post-build events but rather with *.targets, but that doesn't make any difference for the user.
- Home - Overview
- Architecture
- Documentation
- Samples Library
- Product Roadmap
- Tips'n'Tricks