-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If INSTALLFOLDER is referenced and not defined, define one with reasonable default values. Implements WIP wixtoolset/issues#7588.
- Loading branch information
Showing
5 changed files
with
109 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
|
||
namespace WixToolset.Core.Link | ||
{ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using WixToolset.Data; | ||
using WixToolset.Data.Symbols; | ||
|
||
internal class AddDefaultSymbolsCommand | ||
{ | ||
public static readonly string WixStandardInstallFolder = "INSTALLFOLDER"; | ||
public static readonly string WixStandardInstallFolderParent = "ProgramFiles6432Folder"; | ||
public static readonly string WixStandardInstallFolderReference = "Directory:INSTALLFOLDER"; | ||
|
||
public AddDefaultSymbolsCommand(FindEntrySectionAndLoadSymbolsCommand find, List<IntermediateSection> sections) | ||
{ | ||
this.Find = find; | ||
this.Sections = sections; | ||
} | ||
|
||
public IntermediateSection EntrySection { get; } | ||
|
||
public IEnumerable<IntermediateSection> Sections { get; } | ||
|
||
public FindEntrySectionAndLoadSymbolsCommand Find { get; } | ||
|
||
public void Execute() | ||
{ | ||
var symbols = this.Sections.SelectMany(s => s.Symbols); | ||
var directorySymbols = symbols.OfType<DirectorySymbol>(); | ||
var referenceSymbols = symbols.OfType<WixSimpleReferenceSymbol>(); | ||
|
||
if (referenceSymbols.Any(s => s.SymbolicName == WixStandardInstallFolderReference) | ||
&& !directorySymbols.Any(d => d.Id.Id == WixStandardInstallFolder)) | ||
{ | ||
// If there are any INSTALLFOLDER references, add a default one, using the | ||
// first reference as the "canonical" reference for source line numbers. | ||
this.AddSymbol(new DirectorySymbol(null, new Identifier(AccessModifier.Global, WixStandardInstallFolder)) | ||
{ | ||
ParentDirectoryRef = WixStandardInstallFolderParent, | ||
Name = "!(bind.Property.Manufacturer) !(bind.Property.ProductName)", | ||
SourceName = ".", | ||
}); | ||
|
||
this.AddSymbol(new WixSimpleReferenceSymbol(null, new Identifier(AccessModifier.Global, WixStandardInstallFolder)) | ||
{ | ||
Table = "Directory", | ||
PrimaryKeys = WixStandardInstallFolderParent, | ||
}); | ||
} | ||
} | ||
|
||
private void AddSymbol(IntermediateSymbol symbol) | ||
{ | ||
this.Find.EntrySection.AddSymbol(symbol); | ||
|
||
var symbolWithSection = new SymbolWithSection(this.Find.EntrySection, symbol); | ||
var fullName = symbolWithSection.GetFullName(); | ||
this.Find.SymbolsByName.Add(fullName, symbolWithSection); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
src/wix/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.wxs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
<Package Name="MsiPackage" Codepage="1252" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" Compressed="no" InstallerVersion="200" Scope="perMachine"> | ||
|
||
|
||
<MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" /> | ||
|
||
<Feature Id="ProductFeature" Title="!(loc.FeatureTitle)"> | ||
<ComponentGroupRef Id="ProductComponents" /> | ||
</Feature> | ||
</Package> | ||
|
||
<Fragment> | ||
<StandardDirectory Id="ProgramFilesFolder"> | ||
<Directory Id="INSTALLFOLDER" Name="MsiPackage" SourceName="." /> | ||
</StandardDirectory> | ||
</Fragment> | ||
</Wix> |