Skip to content

Commit

Permalink
- Removed all references to the obsolete IncludeWixExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-shilo committed Apr 14, 2018
1 parent fcbf9f0 commit 371290e
Show file tree
Hide file tree
Showing 21 changed files with 99 additions and 45 deletions.
24 changes: 22 additions & 2 deletions Source/src/WixSharp.Samples/Support/testpad/setup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//css_ref ..\..\WixSharp.dll;
//css_ref System.Core.dll;
using Microsoft.Deployment.WindowsInstaller;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
Expand All @@ -14,6 +15,23 @@

// Truly a throw away project for dev testing

public class CustomActions
{
[CustomAction]
public static ActionResult MyAction(Session session)
{
MessageBox.Show("Hello World! (CLR: v" + Environment.Version + ")", "Embedded Managed CA (" + (Is64BitProcess ? "x64" : "x86") + ")");
session.Log("Begin MyAction Hello World");

return ActionResult.Success;
}

public static bool Is64BitProcess
{
get { return IntPtr.Size == 8; }
}
}

static class Script
{
static void prepare_dirs(string root)
Expand Down Expand Up @@ -47,9 +65,11 @@ static void Issue_298b()
{
var project =
new Project("MyProduct",
new RegValue(RegistryHive.LocalMachine, @"Software\test", "foo_value", "bar"));
new RegValue(RegistryHive.LocalMachine, @"Software\test", "foo_value", "bar") { Win64 = false },
new RegValue(RegistryHive.LocalMachine, @"Software\test", "foo_value", "bar") { Win64 = true });

project.PreserveTempFiles = true;
project.Platform = Platform.x64;
project.BuildMsi();

// project.GUID = new Guid("6fe30b47-2577-43ad-9095-1861ba25889b");
Expand All @@ -60,7 +80,7 @@ static void Issue_298b()

static public void Main(string[] args)
{
Issue_298b(); return;
Issue_298(); return;
// Compiler.AutoGeneration.LegacyDefaultIdAlgorithm = true;

var serverFeature = new Feature("Server");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static public void Main(string[] args)

project.GUID = new Guid("6fe30b47-2577-43ad-9095-1861ba25889b");

project.IncludeWixExtension(WixExtension.IIs);
project.Include(WixExtension.IIs);
project.WixSourceGenerated += Compiler_WixSourceGenerated;

project.PreserveTempFiles = true;
Expand Down Expand Up @@ -61,7 +61,4 @@ where e.Attribute("Source").Value.EndsWith("Default.aspx")
new XAttribute("Id", "AllUnassigned"),
new XAttribute("Port", "80"))));
}
}



}
4 changes: 2 additions & 2 deletions Source/src/WixSharp.Samples/Wix# Samples/InjectXML/setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static public void Main(string[] args)

// AddXmlInclude can also be applied to any WixShari entity (e.g. new File("...").AddXmlInclude("FileCommonProperies.wxi")

project.IncludeWixExtension(WixExtension.Util)
project.Include(WixExtension.Util)
.AddXmlInclude("CommonProperies.wxi")
.AddXmlInclude("CommonProperies2.wxi");

Expand Down Expand Up @@ -104,7 +104,7 @@ public void Process(ProcessingContext context)
var util = WixExtension.Util;

// reflect new dependency
context.Project.IncludeWixExtension(util);
context.Project.Include(util);

// serialize itself and add to the parent component
context.XParent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ static public void Main(string[] args)

//Note if the property 'PASSWORD' is not preserved as deferred then it will not be available
//from the Project_AfterInstall, which is a deferred custom action.
AutoElements.LagacyDummyDirAlgorithm = true;

var project = new ManagedProject("ManagedSetup",
new User
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ static void project_Load(SetupEventArgs e)
MessageBox.Show("Hello World! (CLR: v" + Environment.Version + ")", "Managed Setup - Load");

var msi = e.MsiFile;
if (!e.IsInstalling && !e.IsUpgrading) ;
SetEnvVersion(e.Session);
if (!e.IsInstalling && !e.IsUpgrading)
SetEnvVersion(e.Session);

//MSI doesn't preserve any e.Session properties if they are accessed from deferred actions (e.g. project_AfterInstall)
//Wix# forces some of the properties to be persisted (via CustomActionData) by using user defined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static public void Main()
new PropertyRef("NETFRAMEWORK20"),
new ManagedAction(CustomActions.MyAction, Return.check, When.After, Step.InstallInitialize, Condition.NOT_BeingRemoved));

project.IncludeWixExtension(WixExtension.NetFx);
project.Include(WixExtension.NetFx);

Compiler.BuildMsi(project);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/src/WixSharp.Samples/Wix# Samples/Rollback/setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static public void Main(string[] args)
}
};

project.IncludeWixExtension(WixExtension.Util);
project.Include(WixExtension.Util);

Compiler.PreserveTempFiles = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ static void Main(string[] args)
new UrlReservation("http://+:2131/url/device_service/", "*S-1-1-0", UrlReservationRights.register));

project.GUID = new Guid("EC18F80D-2528-4C85-848A-B485401B6523");
project.IncludeWixExtension(WixExtension.Util)
.IncludeWixExtension(WixExtension.Http);
project.Include(WixExtension.Util)
.Include(WixExtension.Http);

Compiler.PreserveTempFiles = true;
Compiler.BuildMsi(project);
Expand Down
18 changes: 16 additions & 2 deletions Source/src/WixSharp.Samples/WixSharp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,20 @@
</para>
</summary>
</member>
<member name="F:WixSharp.AutoElements.UACWarning">
<summary>
The UAC warning message to be displayed at the start of the actual installation (Progress dialog)
of the ManagedUI setup.
<para>The purpose of this message is to draw user attention to the fact that Windows UAC prompt may not
become visible and instead be minimized on the taskbar.
</para>
<remarks>
Windows prevents UIC prompt from stealing the focus if at the time of elevation user performs
interaction with other foreground process (application). It is a controversial aspect of Windows
User Experience that sometimes has undesirable practical implications.
</remarks>
</summary>
</member>
<member name="F:WixSharp.AutoElements.ForceCDataForConditions">
<summary>
Forces all <see cref="T:WixSharp.Condition"/> values to be always encoded as CDATA.
Expand Down Expand Up @@ -13979,7 +13993,7 @@
</member>
<member name="F:WixSharp.XmlFile.Action">
<summary>
The type of modification to be made to the XML file when the component is installed.
The type of modification to be made to the XML file when the component is installed.
</summary>
</member>
<member name="F:WixSharp.XmlFile.ElementPath">
Expand Down Expand Up @@ -14011,7 +14025,7 @@
<member name="F:WixSharp.XmlFile.Sequence">
<summary>
Specifies the order in which the modification is to be attempted on the XML file.
It is important to ensure that new elements are created before you attempt to add an attribute to them.
It is important to ensure that new elements are created before you attempt to add an attribute to them.
</summary>
</member>
<member name="F:WixSharp.XmlFile.SelectionLanguage">
Expand Down
2 changes: 1 addition & 1 deletion Source/src/WixSharp/Certificate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public Certificate(Id id, Feature feature, string name, StoreLocation storeLocat
/// <param name="context">The context.</param>
public void Process(ProcessingContext context)
{
context.Project.IncludeWixExtension(WixExtension.IIs);
context.Project.Include(WixExtension.IIs);

XElement component = this.CreateParentComponent();
component.Add(this.ToXElement(WixExtension.IIs, "Certificate"));
Expand Down
2 changes: 1 addition & 1 deletion Source/src/WixSharp/CommonTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ static public Project SetNetFxPrerequisite(this WixSharp.Project project, string
foreach (var prop in condition.GetDistinctProperties())
project.AddProperty(new PropertyRef(prop));

project.IncludeWixExtension(WixExtension.NetFx);
project.Include(WixExtension.NetFx);

return project;
}
Expand Down
38 changes: 31 additions & 7 deletions Source/src/WixSharp/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ public static XDocument GenerateWixProj(Project project)
product.AddElement("UIRef", $"Id={project.UI}");
product.AddElement("UIRef", "Id=WixUI_ErrorProgressText");

project.IncludeWixExtension(WixExtension.UI);
project.Include(WixExtension.UI);
}

if (project.EmbeddedUI != null)
Expand Down Expand Up @@ -1475,6 +1475,24 @@ static XElement GetTopLevelDir(XElement product)
return prevDir;
}

static XElement GetTopLevelPermanentDir(XElement product, bool is64)
{
// "Program Files" dir is guaranteed to be on all OS flavors
var dirName = is64 ? "ProgramFiles64Folder" : "ProgramFilesFolder";

XElement dir = product.Elements("Directory").First();
while (dir != null)
{
if (dir.HasAttribute("Name", dirName))
return dir; //dir containing installable items (e.g. files or shortcuts)

dir = dir.Elements("Directory").FirstOrDefault();
}

// nothing has been found so create it
return product.Elements("Directory").First().AddElement("Directory", $"Id={dirName};Name={dirName}");
}

static void ProcessFeatures(Project project, XElement product, Dictionary<Feature, List<string>> featureComponents, List<string> autoGeneratedComponents, List<string> defaultFeatureComponents)
{
if (!featureComponents.ContainsKey(project.DefaultFeature))
Expand Down Expand Up @@ -1977,7 +1995,7 @@ static void ProcessFilePermissions(Project wProject, File wFile, XElement file)
if (wFile.Permissions.Any())
{
var utilExtension = WixExtension.Util;
wProject.IncludeWixExtension(utilExtension);
wProject.Include(utilExtension);

foreach (var permission in wFile.Permissions)
{
Expand All @@ -1993,7 +2011,7 @@ static void ProcessDirPermissions(Dir wDir, Project wProject, Dictionary<Feature
if (wDir.Permissions.Any())
{
var utilExtension = WixExtension.Util;
wProject.IncludeWixExtension(utilExtension);
wProject.Include(utilExtension);

foreach (var permission in wDir.Permissions)
{
Expand Down Expand Up @@ -2294,7 +2312,13 @@ static void ProcessRegKeys(Project wProject, Dictionary<Feature, List<string>> f
else
defaultFeatureComponents.Add(compId);

XElement topLevelDir = GetTopLevelDir(product);
// WiX/MSI requires the registry to belong to directory
// (either by nesting XML element or bu having Directory attribute in the registry key component)
// Instead of placing the reg component into the user dir element place it in the ProgramFiles
// dir element. This dir is not going to be created nor deleted during the installation.
// This technique is only used to satisfy WiX/MSI constraint for `Component.RegistryKey` to belong to the directory.
XElement topLevelDir = GetTopLevelPermanentDir(product, regVal.Win64);

XElement comp = topLevelDir.AddElement(
new XElement("Component",
new XAttribute("Id", compId),
Expand Down Expand Up @@ -2351,7 +2375,7 @@ static void ProcessUrlReservations(Project project, Dictionary<Feature, List<str
{
if (!project.UrlReservations.Any()) return;

project.IncludeWixExtension(WixExtension.Http);
project.Include(WixExtension.Http);

int componentCount = 0;
foreach (UrlReservation item in project.UrlReservations)
Expand Down Expand Up @@ -2507,7 +2531,7 @@ static void InsertIISElements(XElement dirItem, XElement component, IISVirtualDi

if (wasInserted)
{
project.IncludeWixExtension(WixExtension.IIs);
project.Include(WixExtension.IIs);
}
}

Expand Down Expand Up @@ -2950,7 +2974,7 @@ static void ProcessCustomActions(Project wProject, XElement product)
.AddAttributes(wAction.Attributes));
}

wProject.IncludeWixExtension(WixExtension.Util);
wProject.Include(WixExtension.Util);
}
else if (wAction is InstalledFileAction)
{
Expand Down
4 changes: 2 additions & 2 deletions Source/src/WixSharp/FirewallException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,15 @@ public FirewallException(Id id, string name)
/// <param name="context">The context.</param>
public void Process(ProcessingContext context)
{
context.Project.IncludeWixExtension(WixExtension.Fire);
context.Project.Include(WixExtension.Fire);

var firewallElement = this.ToXElement(WixExtension.Fire, "FirewallException");

RemoteAddress.ForEach(address =>
{
firewallElement.Add(WixExtension.Fire.XElement("RemoteAddress", (object)address.Trim()));
});

var findComponent = context.XParent.FindFirst("Component");

if (findComponent != null)
Expand Down
2 changes: 1 addition & 1 deletion Source/src/WixSharp/InternetShortcut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public enum ShortcutType
public void Process(ProcessingContext context)
{
this.Id = this.Id ?? base.Id; // ensure the auto-generated Id is pushed to the XML attribute
context.Project.IncludeWixExtension(WixExtension.Util);
context.Project.Include(WixExtension.Util);

context.XParent
.FindFirst("Component")
Expand Down
2 changes: 1 addition & 1 deletion Source/src/WixSharp/NativeImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void Process(ProcessingContext context)
{
var util = WixExtension.NetFx;

context.Project.IncludeWixExtension(util);
context.Project.Include(util);

//serialize itself and add to the parent component
context.XParent
Expand Down
2 changes: 1 addition & 1 deletion Source/src/WixSharp/ServiceInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ XElement ServiceInstallToXml(Project project)
|| ResetPeriodInDays.HasValue
|| RestartServiceDelayInSeconds.HasValue)
{
project?.IncludeWixExtension(WixExtension.Util);
project?.Include(WixExtension.Util);

var serviceConfig = new XElement(WixExtension.Util.ToXNamespace() + "ServiceConfig");

Expand Down
2 changes: 1 addition & 1 deletion Source/src/WixSharp/SqlDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ internal bool MustDescendFromComponent
/// <param name="context">The context.</param>
public void Process(ProcessingContext context)
{
context.Project.IncludeWixExtension(WixExtension.Sql);
context.Project.Include(WixExtension.Sql);

if (MustDescendFromComponent)
{
Expand Down
4 changes: 2 additions & 2 deletions Source/src/WixSharp/SqlScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public SqlScript(Id id, Binary binary, ExecuteSql executeOptions)
/// <param name="sqlDb"></param>
/// <param name="binaryKey"></param>
/// <param name="executeOptions"></param>
public SqlScript(Id id, string sqlDb,string binaryKey, ExecuteSql executeOptions)
public SqlScript(Id id, string sqlDb, string binaryKey, ExecuteSql executeOptions)
: this(binaryKey, executeOptions)
{
Id = id;
Expand Down Expand Up @@ -759,7 +759,7 @@ public void Process(ProcessingContext context)
{
if (SqlDb != null)
{
context.Project.IncludeWixExtension(WixExtension.Sql);
context.Project.Include(WixExtension.Sql);

XElement component = this.CreateParentComponent();
XElement sqlScript = this.ToXElement(WixExtension.Sql, "SqlScript");
Expand Down
2 changes: 1 addition & 1 deletion Source/src/WixSharp/SqlString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public void Process(ProcessingContext context)
{
if (SqlDb != null)
{
context.Project.IncludeWixExtension(WixExtension.Sql);
context.Project.Include(WixExtension.Sql);

XElement component = this.CreateParentComponent();
XElement sqlString = this.ToXElement(WixExtension.Sql, "SqlString");
Expand Down
5 changes: 2 additions & 3 deletions Source/src/WixSharp/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public void Process(ProcessingContext context)
{
if (MustDescendFromComponent)
{
context.Project.IncludeWixExtension(WixExtension.Util);
context.Project.Include(WixExtension.Util);

XElement component = this.CreateParentComponent();
component.Add(this.ToXElement(WixExtension.Util, "User"));
Expand All @@ -268,11 +268,10 @@ public void Process(ProcessingContext context)
}
else
{
context.Project.IncludeWixExtension(WixExtension.Util);
context.Project.Include(WixExtension.Util);

context.XParent.Add(this.ToXElement(WixExtension.Util, "User"));
}

}
}
}
Loading

0 comments on commit 371290e

Please sign in to comment.