-
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
6 changed files
with
157 additions
and
40 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
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,69 @@ | ||
// 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, IList<IntermediateSection> sections) | ||
{ | ||
this.Find = find; | ||
this.Sections = sections; | ||
} | ||
|
||
public IList<IntermediateSection> Sections { get; } | ||
|
||
public FindEntrySectionAndLoadSymbolsCommand Find { get; } | ||
|
||
public void Execute() | ||
{ | ||
if (this.Find.EntrySection.Type != SectionType.Package) | ||
{ | ||
// Only packages...for now. | ||
return; | ||
} | ||
|
||
if (!this.Find.SymbolsByName.ContainsKey(WixStandardInstallFolderReference)) | ||
{ | ||
var sourceLineNumber = new SourceLineNumber("DefaultInstallFolder"); | ||
|
||
this.AddSymbolsToNewSection(WixStandardInstallFolder, | ||
new DirectorySymbol(sourceLineNumber, new Identifier(AccessModifier.Global, WixStandardInstallFolder)) | ||
{ | ||
ParentDirectoryRef = WixStandardInstallFolderParent, | ||
Name = "!(bind.Property.Manufacturer) !(bind.Property.ProductName)", | ||
SourceName = ".", | ||
}, | ||
new WixSimpleReferenceSymbol(sourceLineNumber, new Identifier(AccessModifier.Global, WixStandardInstallFolder)) | ||
{ | ||
Table = "Directory", | ||
PrimaryKeys = WixStandardInstallFolderParent, | ||
} | ||
); | ||
} | ||
} | ||
|
||
private void AddSymbolsToNewSection(string sectionId, params IntermediateSymbol[] symbols) | ||
{ | ||
var section = new IntermediateSection(sectionId, SectionType.Fragment); | ||
this.Sections.Add(section); | ||
|
||
foreach (var symbol in symbols) | ||
{ | ||
section.AddSymbol(symbol); | ||
|
||
var symbolWithSection = new SymbolWithSection(section, 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> |