Skip to content

Commit

Permalink
- Added support for UI.Error WiX element
Browse files Browse the repository at this point in the history
- Issue #552: Question: Install 2 windows services in same installer
  • Loading branch information
lbs-contributor committed Jan 18, 2019
1 parent 8846d47 commit 14edaf2
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 46 deletions.
Expand Up @@ -5,15 +5,15 @@
//css_ref Wix_bin\SDK\Microsoft.Deployment.WindowsInstaller.dll;

using System;
using System.Diagnostics;
using System.Linq;
using System.Xml.Linq;
using System.Windows.Forms;
using System.Xml;
using sys = System.Reflection;
using System.Xml.Linq;
using Microsoft.Deployment.WindowsInstaller;
using WixSharp;
using WixSharp.Bootstrapper;
using Microsoft.Deployment.WindowsInstaller;
using System.Windows.Forms;
using System.Diagnostics;
using sys = System.Reflection;

public class InstallScript
{
Expand All @@ -32,14 +32,14 @@ static public void Main()
var productMsi = productProj.BuildMsi();

var bootstrapper =
new Bundle("My Product Suite",
new PackageGroupRef("NetFx40Web"),
new MsiPackage(productMsi)
{
Id = "MyProductPackageId",
DisplayInternalUI = true,
Visible = true // show MSI entry in ARP
});
new Bundle("My Product Suite",
new PackageGroupRef("NetFx40Web"),
new MsiPackage(productMsi)
{
Id = "MyProductPackageId",
DisplayInternalUI = true,
Visible = true // show MSI entry in ARP
});

bootstrapper.SuppressWixMbaPrereqVars = true; //needed because NetFx40Web also defines WixMbaPrereqVars
bootstrapper.Version = new Version("1.0.0.0");
Expand Down Expand Up @@ -83,7 +83,7 @@ public void Process(ProcessingContext context)
context.Project.Include(WixExtension.Bal); //indicate that candle needs to use WixBlExtension.dll

var element = new XElement(WixExtension.Bal.ToXName("Condition"), Condition)
.SetAttribute("Message", Message);
.SetAttribute("Message", Message);

context.XParent.Add(element);
}
Expand Down
Expand Up @@ -28,14 +28,14 @@ static public void Main()
//------------------------------------

var bootstrapper =
new Bundle("My Product",
new PackageGroupRef("NetFx40Web"),
new MsiPackage(productMsi)
{
Id = "MyProductPackageId",
DisplayInternalUI = true,
MsiProperties = "USERINPUT=[UserInput]"
});
new Bundle("My Product",
new PackageGroupRef("NetFx40Web"),
new MsiPackage(productMsi)
{
Id = "MyProductPackageId",
DisplayInternalUI = true,
MsiProperties = "USERINPUT=[UserInput]"
});

bootstrapper.Variables = new[] { new Variable("UserInput", "<none>"), };
bootstrapper.Version = new Version("1.0.0.0");
Expand Down
12 changes: 6 additions & 6 deletions Source/src/WixSharp.Samples/Wix# Samples/Install Files/setup.cs
Expand Up @@ -20,12 +20,12 @@ static public void Main()
new Project("MyProduct",
new Dir(new Id("MY_INSTALLDIR"), @"%ProgramFiles%\My Company\My Product",
f = new File("MyApp_file".ToId(),
@"Files\Bin\MyApp.exe",
new FileAssociation("cstm", "application/custom", "open", "\"%1\"")
{
Advertise = true,
Icon = "wixsharp.ico"
})
@"Files\Bin\MyApp.exe",
new FileAssociation("cstm", "application/custom", "open", "\"%1\"")
{
Advertise = true,
Icon = "wixsharp.ico"
})
{
TargetFileName = "app.exe"
},
Expand Down
12 changes: 5 additions & 7 deletions Source/src/WixSharp.Samples/Wix# Samples/Reboot/setup.cs
Expand Up @@ -3,12 +3,12 @@
//css_ref System.Core.dll;

using System;
using System.Windows.Forms;
using System.Diagnostics;
using System.Windows.Forms;
using Microsoft.Deployment.WindowsInstaller;
using Microsoft.Win32;
using WixSharp;
using WixSharp.CommonTasks;
using Microsoft.Win32;

class Script
{
Expand Down Expand Up @@ -36,11 +36,9 @@ public class CustonActions
[CustomAction]
public static ActionResult PromptToReboot(Session session)
{
Record record = new Record(1)
{
[1] = "9000",
};

var record = new Record(1);
record[1] = "9000";
// Using `Record` only as example. Otherwise the direct WinForm message can be used instead.
if (MessageResult.Yes == session.Message(InstallMessage.User | (InstallMessage)MessageButtons.YesNo | (InstallMessage)MessageIcon.Question, record))
{
Process.Start("shutdown.exe", "-r -t 30 -c \"Reboot has been requested from RebootTest.msi\"");
Expand Down
Expand Up @@ -14,11 +14,13 @@ static public void Main()
try
{
File service;
File service2;

var project =
new Project("My Product",
new Dir(@"%ProgramFiles%\My Company\My Product",
service = new File(@"..\SimpleService\MyApp.exe")));
service = new File(@"..\SimpleService\MyApp.exe"),
service2 = new File(@"..\SimpleService\MyApp2.exe")));

//The service file element can also be located as in the following commented code
//File service = project.FindFile(f => f.Name.EndsWith("MyApp.exe"));
Expand Down Expand Up @@ -47,6 +49,28 @@ static public void Main()
},
};

service2.ServiceInstaller = new ServiceInstaller
{
Name = "WixSharp.TestSvc2",
StartOn = SvcEvent.Install, //set it to null if you don't want service to start as during deployment
StopOn = SvcEvent.InstallUninstall_Wait,
RemoveOn = SvcEvent.Uninstall_Wait,
DelayedAutoStart = true,
ServiceSid = ServiceSid.none,
FirstFailureActionType = FailureActionType.restart,
SecondFailureActionType = FailureActionType.restart,
ThirdFailureActionType = FailureActionType.runCommand,
ProgramCommandLine = "MyApp.exe -run",
RestartServiceDelayInSeconds = 30,
ResetPeriodInDays = 1,
PreShutdownDelay = 1000 * 60 * 3,
RebootMessage = "Failure actions do not specify reboot",
DependsOn = new[]
{
new ServiceDependency("Dnscache"),
new ServiceDependency("Dhcp"),
},
};
project.GUID = new Guid("6fe30b47-2577-43ad-9195-1861ba25889b");
project.OutFileName = "setup";

Expand Down
20 changes: 12 additions & 8 deletions Source/src/WixSharp/Error.cs
@@ -1,7 +1,17 @@
namespace WixSharp
{
/// <summary>
/// Implements `Error` element that can be used to define and customize runtime error messages.
/// </summary>
/// <seealso cref="WixSharp.WixEntity" />
/// <seealso cref="WixSharp.IGenericEntity" />
public class Error : WixEntity, IGenericEntity
{
/// <summary>
/// Initializes a new instance of the <see cref="Error"/> class.
/// </summary>
/// <param name="id">The identifier.</param>
/// <param name="message">The message.</param>
public Error(string id, string message)
{
Id = id;
Expand All @@ -14,14 +24,8 @@ public Error(string id, string message)
[Xml]
private new string Id
{
get
{
return base.Id;
}
set
{
base.Id = value;
}
get => base.Id;
set => base.Id = value;
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Source/src/WixSharp/SvcEvent.cs
Expand Up @@ -9,7 +9,7 @@ public class SvcEvent : WixEntity, IGenericEntity
/// <summary>
/// Specifies when the service action occur. It can be one of the <see cref="SvcEventType"/> values.
/// </summary>
protected internal SvcEventType Type;
public SvcEventType Type;

/// <summary>
/// Predefined instance of <see cref="SvcEvent"/> with <c>Type</c> set to <see cref="SvcEventType.install"/>
Expand Down Expand Up @@ -92,7 +92,7 @@ public class SvcEvent : WixEntity, IGenericEntity
[Xml]
public SvcEventType? Stop;

private SvcEvent()
public SvcEvent()
{
}

Expand Down

0 comments on commit 14edaf2

Please sign in to comment.