Skip to content

Commit

Permalink
Issue #45: Can't install dll to windows/system32 - added compile warn…
Browse files Browse the repository at this point in the history
…ing on special folder dirId reassignment
  • Loading branch information
oleg-shilo committed Mar 28, 2017
1 parent af31062 commit 46758d2
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ class Script
{
static public void Main(string[] args)
{
//Compiler.AutoGeneration.InstallDirDefaultId = null;

var project =
new Project("MyProduct",
new Dir(@"%ProgramFiles%\My Company\My Product",
//new Dir(@"%ProgramFiles%\My Company\My Product",
new Dir(@"%SystemFolder%",
//new Dir(new Id("SystemFolder"), "System",
new File(new Id("MyApp_file"), @"Files\Bin\MyApp.exe")),
new Dir(@"Docs\Manual",
new File(@"Files\Docs\Manual.txt")
Expand Down
Binary file modified Source/src/WixSharp.Samples/WixSharp.UI.dll
Binary file not shown.
Binary file modified Source/src/WixSharp.Samples/WixSharp.dll
Binary file not shown.
58 changes: 58 additions & 0 deletions Source/src/WixSharp.Samples/WixSharp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,12 @@
is false or omitted and the bundle is being installed, Burn will install this package.
</summary>
</member>
<member name="F:WixSharp.Bootstrapper.ExePackage.ExitCodes">
<summary>
Describes map of exit code returned from executable package to a bootstrapper behavior.
http://wixtoolset.org/documentation/manual/v3/xsd/wix/exitcode.html
</summary>
</member>
<member name="M:WixSharp.Bootstrapper.ExePackage.ToXml">
<summary>
Emits WiX XML.
Expand Down Expand Up @@ -1624,6 +1630,49 @@
</summary>
<returns></returns>
</member>
<member name="F:WixSharp.Bootstrapper.ExitCode.Value">
<summary>
Exit code returned from executable package.
If no value is provided it means all values not explicitly set default to this behavior.
</summary>
</member>
<member name="F:WixSharp.Bootstrapper.ExitCode.Behavior">
<summary>
Choose one of the supported behaviors error codes: success, error, scheduleReboot, forceReboot.
This attribute's value must be one of the following:
success
error
scheduleReboot
forceReboot
</summary>
</member>
<member name="M:WixSharp.Bootstrapper.ExitCode.ToXElement">
<summary>
Serializes the <see cref="T:WixSharp.Bootstrapper.ExitCode"/> into XML based on the members marked with
<see cref="T:WixSharp.XmlAttribute"/> and <see cref="P:WixSharp.WixObject.Attributes"/>.
</summary>
<returns></returns>
</member>
<member name="F:WixSharp.Bootstrapper.BehaviorValues.success">
<summary>
return success on specified error code
</summary>
</member>
<member name="F:WixSharp.Bootstrapper.BehaviorValues.error">
<summary>
return error on specified error code
</summary>
</member>
<member name="F:WixSharp.Bootstrapper.BehaviorValues.scheduleReboot">
<summary>
schedule reboot on specified error code
</summary>
</member>
<member name="F:WixSharp.Bootstrapper.BehaviorValues.forceReboot">
<summary>
force reboot on specified error code
</summary>
</member>
<member name="F:WixSharp.Bootstrapper.SearchResult.exists">
<summary>
Saves true if a matching registry entry or file is found; false otherwise.
Expand Down Expand Up @@ -4137,6 +4186,15 @@
<param name="data">The data.</param>
<returns></returns>
</member>
<member name="M:WixSharp.Extensions.IsWixConstant(System.String)">
<summary>
Determines whether the value is a WiX constant (e.g. 'SystenFolder').
</summary>
<param name="value">The value.</param>
<returns>
<c>true</c> if the specified value is a WiX constant; otherwise, <c>false</c>.
</returns>
</member>
<member name="M:WixSharp.Extensions.Map64Dirs(System.String)">
<summary>
Maps the Wix# constants included in path into their x64 equivalents.
Expand Down
5 changes: 5 additions & 0 deletions Source/src/WixSharp/Bootstrapper/Packages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ public class ExitCode
[Xml]
public BehaviorValues Behavior;

/// <summary>
/// Serializes the <see cref="WixSharp.Bootstrapper.ExitCode"/> into XML based on the members marked with
/// <see cref="WixSharp.XmlAttribute"/> and <see cref="WixSharp.WixObject.Attributes"/>.
/// </summary>
/// <returns></returns>
public XElement ToXElement()
{
var element = new XElement("ExitCode", new XAttribute("Behavior", Behavior));
Expand Down
31 changes: 18 additions & 13 deletions Source/src/WixSharp/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ static void EnsureVSIntegration()
{
if (injected)
{
auto_gen_elements.ToList().ForEach(e=>e.Remove());
auto_gen_elements.ToList().ForEach(e => e.Remove());
doc.Save(projFile);
}
}
Expand Down Expand Up @@ -1161,7 +1161,7 @@ public static XDocument GenerateWixProj(Project project)
package.CopyAttributeFrom(product, "Id");

package.AddAttributes(project.Package.Attributes);
foreach(Media item in project.Media)
foreach (Media item in project.Media)
product.Add(item.ToXml((project as WixEntity).Id));

ProcessWixVariables(project, product);
Expand Down Expand Up @@ -1326,8 +1326,13 @@ static string AutoAssignInstallDirId(Dir[] wDirs, string dirId)
logicalPath += "\\" + firstDirWithItems.Name;
}

if ((!firstDirWithItems.IsIdSet() || firstDirWithItems.isAutoId) && !Compiler.AutoGeneration.InstallDirDefaultId.IsEmpty())
if ((!firstDirWithItems.IsIdSet() || firstDirWithItems.isAutoId) &&
!dirId.IsEmpty())
{
if (firstDirWithItems.Id.IsWixConstant())
Compiler.OutputWriteLine($"WARNING: Special folder directory ID '{firstDirWithItems.Id}' has been reset to '{dirId}'.\n" +
"If it was not intended disable auto assignment by setting 'Compiler.AutoGeneration.InstallDirDefaultId' to null.\n");

firstDirWithItems.Id = dirId;
return logicalPath;
}
Expand Down Expand Up @@ -1671,7 +1676,7 @@ static void ProcessDirectoryFiles(Dir wDir, Project wProject, Dictionary<Feature
file.Add(new XAttribute("KeyPath", "yes"),
new XAttribute("Assembly", ".net"),
new XAttribute("AssemblyManifest", fileId),
new XAttribute("ProcessorArchitecture", ((Assembly) wFile).ProcessorArchitecture.ToString()));
new XAttribute("ProcessorArchitecture", ((Assembly)wFile).ProcessorArchitecture.ToString()));
}


Expand Down Expand Up @@ -2686,7 +2691,7 @@ static void ProcessCustomActions(Project wProject, XElement product)

if (wAction is SetPropertyAction)
{
var wSetPropAction = (SetPropertyAction) wAction;
var wSetPropAction = (SetPropertyAction)wAction;

var actionId = wSetPropAction.Id;

Expand All @@ -2707,7 +2712,7 @@ static void ProcessCustomActions(Project wProject, XElement product)
}
else if (wAction is ScriptFileAction)
{
var wScriptAction = (ScriptFileAction) wAction;
var wScriptAction = (ScriptFileAction)wAction;

sequences.ForEach(sequence =>
sequence.Add(new XElement("Custom", wAction.Condition.ToXValue(),
Expand All @@ -2729,7 +2734,7 @@ static void ProcessCustomActions(Project wProject, XElement product)
}
else if (wAction is ScriptAction)
{
var wScriptAction = (ScriptAction) wAction;
var wScriptAction = (ScriptAction)wAction;

sequences.ForEach(sequence =>
sequence.Add(new XElement("Custom", wAction.Condition.ToXValue(),
Expand All @@ -2747,7 +2752,7 @@ static void ProcessCustomActions(Project wProject, XElement product)
}
else if (wAction is ManagedAction)
{
var wManagedAction = (ManagedAction) wAction;
var wManagedAction = (ManagedAction)wAction;
var asmFile = Utils.PathCombine(wProject.SourceBaseDir, wManagedAction.ActionAssembly);
var packageFile = asmFile.PathChangeDirectory(wProject.OutDir.PathGetFullPath())
.PathChangeExtension(".CA.dll");
Expand Down Expand Up @@ -2819,7 +2824,7 @@ static void ProcessCustomActions(Project wProject, XElement product)
}
else if (wAction is WixQuietExecAction)
{
var quietExecAction = (WixQuietExecAction) wAction;
var quietExecAction = (WixQuietExecAction)wAction;
var cmdLineActionId = wAction.Name.Expand();
var setCmdLineActionId = "Set_" + cmdLineActionId;

Expand Down Expand Up @@ -2856,7 +2861,7 @@ static void ProcessCustomActions(Project wProject, XElement product)
}
else if (wAction is InstalledFileAction)
{
var fileAction = (InstalledFileAction) wAction;
var fileAction = (InstalledFileAction)wAction;

sequences.ForEach(sequence =>
sequence.Add(
Expand All @@ -2877,7 +2882,7 @@ static void ProcessCustomActions(Project wProject, XElement product)
}
else if (wAction is BinaryFileAction)
{
var binaryAction = (BinaryFileAction) wAction;
var binaryAction = (BinaryFileAction)wAction;

sequences.ForEach(sequence =>
sequence.Add(
Expand All @@ -2898,7 +2903,7 @@ static void ProcessCustomActions(Project wProject, XElement product)
}
else if (wAction is PathFileAction)
{
var fileAction = (PathFileAction) wAction;
var fileAction = (PathFileAction)wAction;

sequences.ForEach(sequence =>
sequence.Add(
Expand Down Expand Up @@ -2946,7 +2951,7 @@ static public string ClientAssembly
foreach (var item in AppDomain.CurrentDomain.GetAssemblies())
try
{
var attr = (System.Reflection.AssemblyDescriptionAttribute) item.GetCustomAttributes(typeof(System.Reflection.AssemblyDescriptionAttribute), false).FirstOrDefault();
var attr = (System.Reflection.AssemblyDescriptionAttribute)item.GetCustomAttributes(typeof(System.Reflection.AssemblyDescriptionAttribute), false).FirstOrDefault();
if (attr != null && IO.File.Exists(attr.Description))
{
clientAssembly = item.Location;
Expand Down
12 changes: 12 additions & 0 deletions Source/src/WixSharp/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,18 @@ public static bool ContainsWixConstants(this string data)
return data.Contains("[") || data.Contains("]");
}

/// <summary>
/// Determines whether the value is a WiX constant (e.g. 'SystenFolder').
/// </summary>
/// <param name="value">The value.</param>
/// <returns>
/// <c>true</c> if the specified value is a WiX constant; otherwise, <c>false</c>.
/// </returns>
public static bool IsWixConstant(this string value)
{
return Compiler.EnvironmentConstantsMapping.ContainsValue(value);
}

/// <summary>
/// Maps the Wix# constants included in path into their x64 equivalents.
/// <para>For example %ProgramFiles%\My Company\My Product should be preprocessed into %ProgramFiles64%\My Company\My Product</para>
Expand Down
2 changes: 1 addition & 1 deletion Source/src/WixSharp/ProjectValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static void Validate(Project project)
}

//important to use RawId to avoid triggering Id premature auto-generation
if (project.AllDirs.Count(x => x.RawId == Compiler.AutoGeneration.InstallDirDefaultId || x.IsInstallDir) > 1)
if (project.AllDirs.Count(x => (x.RawId == Compiler.AutoGeneration.InstallDirDefaultId && Compiler.AutoGeneration.InstallDirDefaultId != null) || x.IsInstallDir) > 1)
throw new ValidationException("More than a single Dir marked as InstallDir. Ensure that only a single directory marked as InstallDir with Dir.IsInstallDir property or with the id 'INSTALLDIR' value");

foreach (Dir dir in project.AllDirs)
Expand Down

0 comments on commit 46758d2

Please sign in to comment.