Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new namespace and solve duplicate key issue #802

Merged
merged 9 commits into from
Jun 9, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/scala/com/typesafe/sbt/packager/windows/Keys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ trait WindowsKeys {
val wixFile = TaskKey[File]("wix-file", "The WIX XML file to package with.")
val candleOptions = SettingKey[Seq[String]]("candle-options", "Options to pass to the candle.exe program.")
val lightOptions = SettingKey[Seq[String]]("light-options", "Options to pass to the light.exe program.")
val wixMajorVersion = SettingKey[Int]("wix-major-version", "Major version of the Wix suit.")

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ object WindowsPlugin extends AutoPlugin {
"-cultures:en-us"),
wixProductId := WixHelper.makeGUID,
wixProductUpgradeId := WixHelper.makeGUID,
wixMajorVersion := 4,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to 3, so we remain backwards compatible and the tests run.


maintainer in Windows <<= maintainer,
packageSummary in Windows <<= packageSummary,
packageDescription in Windows <<= packageDescription,
Expand Down Expand Up @@ -88,8 +90,9 @@ object WindowsPlugin extends AutoPlugin {
wixProductConfig <<= (name in Windows, wixPackageInfo, wixFeatures, wixProductLicense) map { (name, product, features, license) =>
WixHelper.makeWixProductConfig(name, product, features, license)
},
wixConfig <<= (name in Windows, wixPackageInfo, wixProductConfig) map { (name, product, nested) =>
WixHelper.makeWixConfig(name, product, nested)
wixConfig <<= (name in Windows, wixPackageInfo, wixMajorVersion, wixProductConfig) map { (name, product, wmv, nested) =>
val namespaceDefinitions = WixHelper.getNameSpaceDefinitions(wmv)
WixHelper.makeWixConfig(name, product, namespaceDefinitions, nested)
},
wixConfig in Windows <<= wixConfig,
wixProductConfig in Windows <<= wixProductConfig,
Expand Down
28 changes: 27 additions & 1 deletion src/main/scala/com/typesafe/sbt/packager/windows/WixHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ case class ComponentFile(
source: String,
editable: Boolean = false
) extends FeatureComponent
/** Define wix namespace definitions, that depend on the major version of Wix tools **/
case class NamespaceDefinitions(
majorVersionNumber: Int,
namespace: String,
utilExtension: String
)
/**
* Will add the directory to the windows path. NOTE: Only one of these
* per MSI.
Expand Down Expand Up @@ -209,9 +215,10 @@ object WixHelper {
def makeWixConfig(
name: String, // package name
product: WindowsProductInfo,
namespaceDefinitions: NamespaceDefinitions,
rest: xml.Node
): xml.Node = {
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>
<Wix xmlns={ namespaceDefinitions.namespace } xmlns:util={ namespaceDefinitions.utilExtension }>
<Product Id={ product.id } Name={ product.title } Language='1033' Version={ product.version } Manufacturer={ product.maintainer } UpgradeCode={ product.upgradeId }>
<Package Description={ product.description } Comments={ product.comments } Manufacturer={ product.maintainer } InstallScope={ product.installScope } InstallerVersion={ product.installerVersion } Compressed={ if (product.compressed) "yes" else "no" }/>
<Media Id='1' Cabinet={ cleanStringForId(name.toLowerCase).takeRight(66) + ".cab" } EmbedCab='yes'/>
Expand All @@ -220,6 +227,25 @@ object WixHelper {
</Wix>
}

/**
* Wix namespace changed from major version 3 to 4.
* TODO: Not sure if schema of 2006 is compatible with major versions < 3
*/
def getNameSpaceDefinitions(majorVersion: Int): NamespaceDefinitions = {
if (majorVersion <= 3)
NamespaceDefinitions(
majorVersion,
namespace = "http://schemas.microsoft.com/wix/2006/wi",
utilExtension = "http://schemas.microsoft.com/wix/UtilExtension"
)
else
NamespaceDefinitions(
majorVersion,
namespace = "http://wixtoolset.org/schemas/v4/wxs",
utilExtension = "http://wixtoolset.org/schemas/v4/wxs/util"
)
}

/**
* Modifies a string to be Wix ID friendly by removing all the bad
* characters and replacing with _. Also limits the width to 70 (rather than
Expand Down