aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.BuildTasks
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.BuildTasks')
-rw-r--r--src/WixToolset.BuildTasks/DoIt.cs51
-rw-r--r--src/WixToolset.BuildTasks/WixCommandLineBuilder.cs16
-rw-r--r--src/WixToolset.BuildTasks/wix.targets23
3 files changed, 58 insertions, 32 deletions
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 @@
2 2
3namespace WixToolset.BuildTasks 3namespace WixToolset.BuildTasks
4{ 4{
5 using System;
6 using System.Collections.Generic;
7 using System.Runtime.InteropServices;
5 using Microsoft.Build.Framework; 8 using Microsoft.Build.Framework;
6 using Microsoft.Build.Utilities; 9 using Microsoft.Build.Utilities;
7 using WixToolset.Core; 10 using WixToolset.Core;
@@ -40,12 +43,14 @@ namespace WixToolset.BuildTasks
40 43
41 public bool NoLogo { get; set; } 44 public bool NoLogo { get; set; }
42 45
43 public ITaskItem[] ObjectFiles { get; set; } 46 public ITaskItem[] LibraryFiles { get; set; }
44 47
45 [Output] 48 [Output]
46 [Required] 49 [Required]
47 public ITaskItem OutputFile { get; set; } 50 public ITaskItem OutputFile { get; set; }
48 51
52 public string OutputType { get; set; }
53
49 public string PdbOutputFile { get; set; } 54 public string PdbOutputFile { get; set; }
50 55
51 public bool Pedantic { get; set; } 56 public bool Pedantic { get; set; }
@@ -84,7 +89,7 @@ namespace WixToolset.BuildTasks
84 89
85 public ITaskItem[] BindInputPaths { get; set; } 90 public ITaskItem[] BindInputPaths { get; set; }
86 public bool BindFiles { get; set; } 91 public bool BindFiles { get; set; }
87 public ITaskItem BindContentsFile{ get; set; } 92 public ITaskItem BindContentsFile { get; set; }
88 public ITaskItem BindOutputsFile { get; set; } 93 public ITaskItem BindOutputsFile { get; set; }
89 public ITaskItem BindBuiltOutputsFile { get; set; } 94 public ITaskItem BindBuiltOutputsFile { get; set; }
90 95
@@ -102,21 +107,20 @@ namespace WixToolset.BuildTasks
102 public string[] SuppressIces { get; set; } 107 public string[] SuppressIces { get; set; }
103 public string AdditionalCub { get; set; } 108 public string AdditionalCub { get; set; }
104 109
105
106
107 public override bool Execute() 110 public override bool Execute()
108 { 111 {
109 try 112 try
110 { 113 {
111 this.ExecuteCore(); 114 this.ExecuteCore();
112 } 115 }
113 catch (BuildException e) 116 catch (Exception e)
114 {
115 this.Log.LogErrorFromException(e);
116 }
117 catch (WixException e)
118 { 117 {
119 this.Log.LogErrorFromException(e); 118 this.Log.LogErrorFromException(e);
119
120 if (e is NullReferenceException || e is SEHException)
121 {
122 throw;
123 }
120 } 124 }
121 125
122 return !this.Log.HasLoggedErrors; 126 return !this.Log.HasLoggedErrors;
@@ -129,27 +133,31 @@ namespace WixToolset.BuildTasks
129 commandLineBuilder.AppendTextUnquoted("build"); 133 commandLineBuilder.AppendTextUnquoted("build");
130 134
131 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile); 135 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
136 commandLineBuilder.AppendSwitchIfNotNull("-outputType ", this.OutputType);
137 commandLineBuilder.AppendIfTrue("-nologo", this.NoLogo);
132 commandLineBuilder.AppendSwitchIfNotNull("-cultures ", this.Cultures); 138 commandLineBuilder.AppendSwitchIfNotNull("-cultures ", this.Cultures);
133 commandLineBuilder.AppendArrayIfNotNull("-d ", this.DefineConstants); 139 commandLineBuilder.AppendArrayIfNotNull("-d ", this.DefineConstants);
134 commandLineBuilder.AppendArrayIfNotNull("-I ", this.IncludeSearchPaths); 140 commandLineBuilder.AppendArrayIfNotNull("-I ", this.IncludeSearchPaths);
135 commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.ReferencePaths); 141 commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.ReferencePaths);
136 commandLineBuilder.AppendIfTrue("-nologo", this.NoLogo);
137 commandLineBuilder.AppendIfTrue("-sval", this.SuppressValidation); 142 commandLineBuilder.AppendIfTrue("-sval", this.SuppressValidation);
138 commandLineBuilder.AppendArrayIfNotNull("-sice ", this.SuppressIces); 143 commandLineBuilder.AppendArrayIfNotNull("-sice ", this.SuppressIces);
139 commandLineBuilder.AppendSwitchIfNotNull("-usf ", this.UnreferencedSymbolsFile); 144 commandLineBuilder.AppendSwitchIfNotNull("-usf ", this.UnreferencedSymbolsFile);
140 commandLineBuilder.AppendSwitchIfNotNull("-cc ", this.CabinetCachePath); 145 commandLineBuilder.AppendSwitchIfNotNull("-cc ", this.CabinetCachePath);
146 commandLineBuilder.AppendSwitchIfNotNull("-intermediatefolder ", this.IntermediateDirectory);
141 commandLineBuilder.AppendSwitchIfNotNull("-contentsfile ", this.BindContentsFile); 147 commandLineBuilder.AppendSwitchIfNotNull("-contentsfile ", this.BindContentsFile);
142 commandLineBuilder.AppendSwitchIfNotNull("-outputsfile ", this.BindOutputsFile); 148 commandLineBuilder.AppendSwitchIfNotNull("-outputsfile ", this.BindOutputsFile);
143 commandLineBuilder.AppendSwitchIfNotNull("-builtoutputsfile ", this.BindBuiltOutputsFile); 149 commandLineBuilder.AppendSwitchIfNotNull("-builtoutputsfile ", this.BindBuiltOutputsFile);
144 commandLineBuilder.AppendSwitchIfNotNull("-wixprojectfile ", this.WixProjectFile); 150 commandLineBuilder.AppendSwitchIfNotNull("-wixprojectfile ", this.WixProjectFile);
145 commandLineBuilder.AppendTextIfNotWhitespace(this.AdditionalOptions); 151 commandLineBuilder.AppendTextIfNotWhitespace(this.AdditionalOptions);
146 152
153 commandLineBuilder.AppendArrayIfNotNull("-bindPath ", this.CalculateBindPathStrings());
147 commandLineBuilder.AppendArrayIfNotNull("-loc ", this.LocalizationFiles); 154 commandLineBuilder.AppendArrayIfNotNull("-loc ", this.LocalizationFiles);
155 commandLineBuilder.AppendArrayIfNotNull("-lib ", this.LibraryFiles);
148 commandLineBuilder.AppendFileNamesIfNotNull(this.SourceFiles, " "); 156 commandLineBuilder.AppendFileNamesIfNotNull(this.SourceFiles, " ");
149 157
150 var commandLineString = commandLineBuilder.ToString(); 158 var commandLineString = commandLineBuilder.ToString();
151 159
152 this.Log.LogMessage(MessageImportance.Normal, commandLineString); 160 this.Log.LogMessage(MessageImportance.Normal, "wix.exe " + commandLineString);
153 161
154 var command = CommandLine.ParseStandardCommandLine(commandLineString); 162 var command = CommandLine.ParseStandardCommandLine(commandLineString);
155 command?.Execute(); 163 command?.Execute();
@@ -160,6 +168,27 @@ namespace WixToolset.BuildTasks
160 this.Log.LogMessageFromText(e.Message, MessageImportance.Normal); 168 this.Log.LogMessageFromText(e.Message, MessageImportance.Normal);
161 } 169 }
162 170
171 private IEnumerable<string> CalculateBindPathStrings()
172 {
173 if (null != this.BindInputPaths)
174 {
175 foreach (var item in this.BindInputPaths)
176 {
177 var path = item.GetMetadata("FullPath");
178
179 var bindName = item.GetMetadata("BindName");
180 if (!String.IsNullOrEmpty(bindName))
181 {
182 yield return String.Concat(bindName, "=", path);
183 }
184 else
185 {
186 yield return path;
187 }
188 }
189 }
190 }
191
163 ///// <summary> 192 ///// <summary>
164 ///// Builds a command line from options in this task. 193 ///// Builds a command line from options in this task.
165 ///// </summary> 194 ///// </summary>
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
49 /// </summary> 49 /// </summary>
50 /// <param name="switchName">Switch to append.</param> 50 /// <param name="switchName">Switch to append.</param>
51 /// <param name="values">Values specified by the user.</param> 51 /// <param name="values">Values specified by the user.</param>
52 public void AppendArrayIfNotNull(string switchName, ITaskItem[] values) 52 public void AppendArrayIfNotNull(string switchName, IEnumerable<ITaskItem> values)
53 { 53 {
54 if (values != null) 54 if (values != null)
55 { 55 {
@@ -65,7 +65,7 @@ namespace WixToolset.BuildTasks
65 /// </summary> 65 /// </summary>
66 /// <param name="switchName">Switch to append.</param> 66 /// <param name="switchName">Switch to append.</param>
67 /// <param name="values">Values specified by the user.</param> 67 /// <param name="values">Values specified by the user.</param>
68 public void AppendArrayIfNotNull(string switchName, string[] values) 68 public void AppendArrayIfNotNull(string switchName, IEnumerable<string> values)
69 { 69 {
70 if (values != null) 70 if (values != null)
71 { 71 {
@@ -77,9 +77,9 @@ namespace WixToolset.BuildTasks
77 } 77 }
78 78
79 /// <summary> 79 /// <summary>
80 /// Build the extensions argument. Each extension is searched in the current folder, user defined search 80 /// Build the extensions argument. Each extension is searched in the current folder, user defined search
81 /// directories (ReferencePath), HintPath, and under Wix Extension Directory in that order. 81 /// directories (ReferencePath), HintPath, and under Wix Extension Directory in that order.
82 /// The order of precednce is based off of that described in Microsoft.Common.Targets's SearchPaths 82 /// The order of precedence is based off of that described in Microsoft.Common.Targets's SearchPaths
83 /// property for the ResolveAssemblyReferences task. 83 /// property for the ResolveAssemblyReferences task.
84 /// </summary> 84 /// </summary>
85 /// <param name="extensions">The list of extensions to include.</param> 85 /// <param name="extensions">The list of extensions to include.</param>
@@ -92,21 +92,19 @@ namespace WixToolset.BuildTasks
92 return; 92 return;
93 } 93 }
94 94
95 string resolvedPath;
96
97 foreach (ITaskItem extension in extensions) 95 foreach (ITaskItem extension in extensions)
98 { 96 {
99 string className = extension.GetMetadata("Class"); 97 string className = extension.GetMetadata("Class");
100 98
101 string fileName = Path.GetFileName(extension.ItemSpec); 99 string fileName = Path.GetFileName(extension.ItemSpec);
102 100
103 if (Path.GetExtension(fileName).Length == 0) 101 if (String.IsNullOrEmpty(Path.GetExtension(fileName)))
104 { 102 {
105 fileName += ".dll"; 103 fileName += ".dll";
106 } 104 }
107 105
108 // First try reference paths 106 // First try reference paths
109 resolvedPath = FileSearchHelperMethods.SearchFilePaths(referencePaths, fileName); 107 var resolvedPath = FileSearchHelperMethods.SearchFilePaths(referencePaths, fileName);
110 108
111 if (String.IsNullOrEmpty(resolvedPath)) 109 if (String.IsNullOrEmpty(resolvedPath))
112 { 110 {
@@ -118,7 +116,7 @@ namespace WixToolset.BuildTasks
118 // Now try the item itself 116 // Now try the item itself
119 resolvedPath = extension.ItemSpec; 117 resolvedPath = extension.ItemSpec;
120 118
121 if (Path.GetExtension(resolvedPath).Length == 0) 119 if (String.IsNullOrEmpty(Path.GetExtension(resolvedPath)))
122 { 120 {
123 resolvedPath += ".dll"; 121 resolvedPath += ".dll";
124 } 122 }
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 @@
646 @(_BindInputs); 646 @(_BindInputs);
647 $(MSBuildAllProjects)" 647 $(MSBuildAllProjects)"
648 Outputs="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile);@(_BindBuiltOutputs)" 648 Outputs="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile);@(_BindBuiltOutputs)"
649 Condition=" '@(Compile)' != '' and ('$(OutputType)' == 'Bundle' or '$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module')"> 649 Condition=" '@(Compile)' != '' ">
650
651 650
652 <PropertyGroup> 651 <PropertyGroup>
652 <OutputFile>$([System.IO.Path]::GetFullPath($(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(TargetName)$(TargetExt)))</OutputFile>
653 <PdbOutputFile>$(TargetPdbDir)%(CultureGroup.OutputFolder)$(TargetPdbName)</PdbOutputFile> 653 <PdbOutputFile>$(TargetPdbDir)%(CultureGroup.OutputFolder)$(TargetPdbName)</PdbOutputFile>
654 </PropertyGroup> 654 </PropertyGroup>
655 655
656 <DoIt 656 <DoIt
657 SourceFiles="@(_CompileWithObjectPath)" 657 SourceFiles="@(_CompileWithObjectPath)"
658 LibraryFiles="@(WixLibProjects);@(_ResolvedWixLibraryPaths)"
658 LocalizationFiles="@(EmbeddedResource)" 659 LocalizationFiles="@(EmbeddedResource)"
659 ObjectFiles="@(CompileObjOutput);@(WixObject);@(WixLibProjects);@(_ResolvedWixLibraryPaths)"
660 660
661 Cultures="%(CultureGroup.Identity)" 661 Cultures="%(CultureGroup.Identity)"
662 662
@@ -665,7 +665,8 @@
665 665
666 IntermediateDirectory="$(IntermediateOutputPath)" 666 IntermediateDirectory="$(IntermediateOutputPath)"
667 667
668 OutputFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(TargetName)$(TargetExt)" 668 OutputFile="$(OutputFile)"
669 OutputType="$(OutputType)"
669 PdbOutputFile="$(PdbOutputFile)" 670 PdbOutputFile="$(PdbOutputFile)"
670 671
671 AdditionalOptions="$(CompilerAdditionalOptions) $(LinkerAdditionalOptions)" 672 AdditionalOptions="$(CompilerAdditionalOptions) $(LinkerAdditionalOptions)"
@@ -1029,8 +1030,7 @@
1029 ================================================================================================ 1030 ================================================================================================
1030 --> 1031 -->
1031 <Target 1032 <Target
1032 Name="ReadPreviousBindInputsAndBuiltOutputs" 1033 Name="ReadPreviousBindInputsAndBuiltOutputs">
1033 Condition=" '$(OutputType)' == 'Bundle' or '$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module' ">
1034 1034
1035 <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindContentsFile)"> 1035 <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindContentsFile)">
1036 <Output TaskParameter="Lines" ItemName="_BindInputs" /> 1036 <Output TaskParameter="Lines" ItemName="_BindInputs" />
@@ -1169,17 +1169,16 @@
1169 ================================================================================================ 1169 ================================================================================================
1170 --> 1170 -->
1171 <Target 1171 <Target
1172 Name="UpdateLinkFileWrites" 1172 Name="UpdateLinkFileWrites">
1173 Condition=" '$(OutputType)' == 'Bundle' or '$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module' ">
1174 1173
1175 <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)"> 1174 <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)">
1176 <Output TaskParameter="Lines" ItemName="FileWrites"/> 1175 <Output TaskParameter="Lines" ItemName="FileWrites"/>
1177 </ReadLinesFromFile> 1176 </ReadLinesFromFile>
1178 1177
1179 <ItemGroup> 1178 <ItemGroup>
1180 <FileWrites Include="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindContentsFile)" /> 1179 <FileWrites Include="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindContentsFile)" Condition=" Exists('$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindContentsFile)') " />
1181 <FileWrites Include="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)" /> 1180 <FileWrites Include="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)" Condition=" Exists('$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)') " />
1182 <FileWrites Include="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile)" /> 1181 <FileWrites Include="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile)" Condition=" Exists('$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile)') " />
1183 </ItemGroup> 1182 </ItemGroup>
1184 1183
1185 <Message Importance="low" Text="Build files after link: @(FileWrites)" /> 1184 <Message Importance="low" Text="Build files after link: @(FileWrites)" />
@@ -1302,7 +1301,7 @@
1302 </ReadLinesFromFile> 1301 </ReadLinesFromFile>
1303 1302
1304 <ItemGroup> 1303 <ItemGroup>
1305 <_FullPathToCopy Include="$(TargetPath)" Condition=" '@(_FullPathToCopy)'=='' " /> 1304 <_FullPathToCopy Include="$(OutputFile)" Condition=" '@(_FullPathToCopy)'=='' " />
1306 <_RelativePath Include="$([MSBuild]::MakeRelative($(FullIntermediateOutputPath), %(_FullPathToCopy.Identity)))" /> 1305 <_RelativePath Include="$([MSBuild]::MakeRelative($(FullIntermediateOutputPath), %(_FullPathToCopy.Identity)))" />
1307 </ItemGroup> 1306 </ItemGroup>
1308 1307