From 39c7e2bb0399802e65a3025c4a73db211e730479 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sun, 1 Oct 2017 14:25:33 -0700 Subject: Add support for BindPaths and building .wixlibs --- src/WixToolset.BuildTasks/DoIt.cs | 51 +++++++++++++++++----- src/WixToolset.BuildTasks/WixCommandLineBuilder.cs | 16 +++---- src/WixToolset.BuildTasks/wix.targets | 23 +++++----- 3 files changed, 58 insertions(+), 32 deletions(-) (limited to 'src/WixToolset.BuildTasks') diff --git a/src/WixToolset.BuildTasks/DoIt.cs b/src/WixToolset.BuildTasks/DoIt.cs index 7688342c..97554bc6 100644 --- a/src/WixToolset.BuildTasks/DoIt.cs +++ b/src/WixToolset.BuildTasks/DoIt.cs @@ -2,6 +2,9 @@ namespace WixToolset.BuildTasks { + using System; + using System.Collections.Generic; + using System.Runtime.InteropServices; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; using WixToolset.Core; @@ -40,12 +43,14 @@ namespace WixToolset.BuildTasks public bool NoLogo { get; set; } - public ITaskItem[] ObjectFiles { get; set; } + public ITaskItem[] LibraryFiles { get; set; } [Output] [Required] public ITaskItem OutputFile { get; set; } + public string OutputType { get; set; } + public string PdbOutputFile { get; set; } public bool Pedantic { get; set; } @@ -84,7 +89,7 @@ namespace WixToolset.BuildTasks public ITaskItem[] BindInputPaths { get; set; } public bool BindFiles { get; set; } - public ITaskItem BindContentsFile{ get; set; } + public ITaskItem BindContentsFile { get; set; } public ITaskItem BindOutputsFile { get; set; } public ITaskItem BindBuiltOutputsFile { get; set; } @@ -102,21 +107,20 @@ namespace WixToolset.BuildTasks public string[] SuppressIces { get; set; } public string AdditionalCub { get; set; } - - public override bool Execute() { try { this.ExecuteCore(); } - catch (BuildException e) - { - this.Log.LogErrorFromException(e); - } - catch (WixException e) + catch (Exception e) { this.Log.LogErrorFromException(e); + + if (e is NullReferenceException || e is SEHException) + { + throw; + } } return !this.Log.HasLoggedErrors; @@ -129,27 +133,31 @@ namespace WixToolset.BuildTasks commandLineBuilder.AppendTextUnquoted("build"); commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile); + commandLineBuilder.AppendSwitchIfNotNull("-outputType ", this.OutputType); + commandLineBuilder.AppendIfTrue("-nologo", this.NoLogo); commandLineBuilder.AppendSwitchIfNotNull("-cultures ", this.Cultures); commandLineBuilder.AppendArrayIfNotNull("-d ", this.DefineConstants); commandLineBuilder.AppendArrayIfNotNull("-I ", this.IncludeSearchPaths); commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.ReferencePaths); - commandLineBuilder.AppendIfTrue("-nologo", this.NoLogo); commandLineBuilder.AppendIfTrue("-sval", this.SuppressValidation); commandLineBuilder.AppendArrayIfNotNull("-sice ", this.SuppressIces); commandLineBuilder.AppendSwitchIfNotNull("-usf ", this.UnreferencedSymbolsFile); commandLineBuilder.AppendSwitchIfNotNull("-cc ", this.CabinetCachePath); + commandLineBuilder.AppendSwitchIfNotNull("-intermediatefolder ", this.IntermediateDirectory); commandLineBuilder.AppendSwitchIfNotNull("-contentsfile ", this.BindContentsFile); commandLineBuilder.AppendSwitchIfNotNull("-outputsfile ", this.BindOutputsFile); commandLineBuilder.AppendSwitchIfNotNull("-builtoutputsfile ", this.BindBuiltOutputsFile); commandLineBuilder.AppendSwitchIfNotNull("-wixprojectfile ", this.WixProjectFile); commandLineBuilder.AppendTextIfNotWhitespace(this.AdditionalOptions); + commandLineBuilder.AppendArrayIfNotNull("-bindPath ", this.CalculateBindPathStrings()); commandLineBuilder.AppendArrayIfNotNull("-loc ", this.LocalizationFiles); + commandLineBuilder.AppendArrayIfNotNull("-lib ", this.LibraryFiles); commandLineBuilder.AppendFileNamesIfNotNull(this.SourceFiles, " "); var commandLineString = commandLineBuilder.ToString(); - this.Log.LogMessage(MessageImportance.Normal, commandLineString); + this.Log.LogMessage(MessageImportance.Normal, "wix.exe " + commandLineString); var command = CommandLine.ParseStandardCommandLine(commandLineString); command?.Execute(); @@ -160,6 +168,27 @@ namespace WixToolset.BuildTasks this.Log.LogMessageFromText(e.Message, MessageImportance.Normal); } + private IEnumerable CalculateBindPathStrings() + { + if (null != this.BindInputPaths) + { + foreach (var item in this.BindInputPaths) + { + var path = item.GetMetadata("FullPath"); + + var bindName = item.GetMetadata("BindName"); + if (!String.IsNullOrEmpty(bindName)) + { + yield return String.Concat(bindName, "=", path); + } + else + { + yield return path; + } + } + } + } + ///// ///// Builds a command line from options in this task. ///// diff --git a/src/WixToolset.BuildTasks/WixCommandLineBuilder.cs b/src/WixToolset.BuildTasks/WixCommandLineBuilder.cs index 9a6a005d..3f3084a3 100644 --- a/src/WixToolset.BuildTasks/WixCommandLineBuilder.cs +++ b/src/WixToolset.BuildTasks/WixCommandLineBuilder.cs @@ -49,7 +49,7 @@ namespace WixToolset.BuildTasks /// /// Switch to append. /// Values specified by the user. - public void AppendArrayIfNotNull(string switchName, ITaskItem[] values) + public void AppendArrayIfNotNull(string switchName, IEnumerable values) { if (values != null) { @@ -65,7 +65,7 @@ namespace WixToolset.BuildTasks /// /// Switch to append. /// Values specified by the user. - public void AppendArrayIfNotNull(string switchName, string[] values) + public void AppendArrayIfNotNull(string switchName, IEnumerable values) { if (values != null) { @@ -77,9 +77,9 @@ namespace WixToolset.BuildTasks } /// - /// Build the extensions argument. Each extension is searched in the current folder, user defined search + /// Build the extensions argument. Each extension is searched in the current folder, user defined search /// directories (ReferencePath), HintPath, and under Wix Extension Directory in that order. - /// The order of precednce is based off of that described in Microsoft.Common.Targets's SearchPaths + /// The order of precedence is based off of that described in Microsoft.Common.Targets's SearchPaths /// property for the ResolveAssemblyReferences task. /// /// The list of extensions to include. @@ -92,21 +92,19 @@ namespace WixToolset.BuildTasks return; } - string resolvedPath; - foreach (ITaskItem extension in extensions) { string className = extension.GetMetadata("Class"); string fileName = Path.GetFileName(extension.ItemSpec); - if (Path.GetExtension(fileName).Length == 0) + if (String.IsNullOrEmpty(Path.GetExtension(fileName))) { fileName += ".dll"; } // First try reference paths - resolvedPath = FileSearchHelperMethods.SearchFilePaths(referencePaths, fileName); + var resolvedPath = FileSearchHelperMethods.SearchFilePaths(referencePaths, fileName); if (String.IsNullOrEmpty(resolvedPath)) { @@ -118,7 +116,7 @@ namespace WixToolset.BuildTasks // Now try the item itself resolvedPath = extension.ItemSpec; - if (Path.GetExtension(resolvedPath).Length == 0) + if (String.IsNullOrEmpty(Path.GetExtension(resolvedPath))) { resolvedPath += ".dll"; } diff --git a/src/WixToolset.BuildTasks/wix.targets b/src/WixToolset.BuildTasks/wix.targets index eadd33ec..bcf0163b 100644 --- a/src/WixToolset.BuildTasks/wix.targets +++ b/src/WixToolset.BuildTasks/wix.targets @@ -646,17 +646,17 @@ @(_BindInputs); $(MSBuildAllProjects)" Outputs="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile);@(_BindBuiltOutputs)" - Condition=" '@(Compile)' != '' and ('$(OutputType)' == 'Bundle' or '$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module')"> - + Condition=" '@(Compile)' != '' "> + $([System.IO.Path]::GetFullPath($(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(TargetName)$(TargetExt))) $(TargetPdbDir)%(CultureGroup.OutputFolder)$(TargetPdbName) + Name="ReadPreviousBindInputsAndBuiltOutputs"> @@ -1169,17 +1169,16 @@ ================================================================================================ --> + Name="UpdateLinkFileWrites"> - - - + + + @@ -1302,7 +1301,7 @@ - <_FullPathToCopy Include="$(TargetPath)" Condition=" '@(_FullPathToCopy)'=='' " /> + <_FullPathToCopy Include="$(OutputFile)" Condition=" '@(_FullPathToCopy)'=='' " /> <_RelativePath Include="$([MSBuild]::MakeRelative($(FullIntermediateOutputPath), %(_FullPathToCopy.Identity)))" /> -- cgit v1.2.3-55-g6feb