diff options
author | Bob Arnson <bob@firegiant.com> | 2021-10-08 10:59:34 -0400 |
---|---|---|
committer | Bob Arnson <bob@firegiant.com> | 2021-10-08 13:59:00 -0400 |
commit | bbf6449da7dd477999b877402fea546eb0801911 (patch) | |
tree | d177919c5b7b31bbbde728506a94f04ae50f465f /src | |
parent | fad58e4d2bbd8e451cdb725325a5d760b4d1a684 (diff) | |
download | wix-bbf6449da7dd477999b877402fea546eb0801911.tar.gz wix-bbf6449da7dd477999b877402fea546eb0801911.tar.bz2 wix-bbf6449da7dd477999b877402fea546eb0801911.zip |
Fix assembly harvesting for NetFx 1.x assemblies.
Don't harvest MSIL `processorArchitecture` for 1.x assemblies.
This matches WiX v3 behavior.
Diffstat (limited to 'src')
6 files changed, 105 insertions, 2 deletions
diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Bind/AssemblyNameReader.cs b/src/wix/WixToolset.Core.WindowsInstaller/Bind/AssemblyNameReader.cs index 2103cd32..5dcfa1e6 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/AssemblyNameReader.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/AssemblyNameReader.cs | |||
@@ -37,8 +37,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
37 | // to be equal to or longer than the "fileVersion" in length when its present; | 37 | // to be equal to or longer than the "fileVersion" in length when its present; |
38 | // the workaround is to prepend zeroes to the last version number in the assembly | 38 | // the workaround is to prepend zeroes to the last version number in the assembly |
39 | // version. | 39 | // version. |
40 | var targetNetfx1 = (headers.CorHeader.MajorRuntimeVersion == 2) && (headers.CorHeader.MinorRuntimeVersion == 0); | 40 | if (IsNetFx1xAssembly(headers) && !String.IsNullOrEmpty(fileVersion) && fileVersion.Length > version.Length) |
41 | if (targetNetfx1 && !String.IsNullOrEmpty(fileVersion) && fileVersion.Length > version.Length) | ||
42 | { | 41 | { |
43 | var versionParts = version.Split('.'); | 42 | var versionParts = version.Split('.'); |
44 | 43 | ||
@@ -154,6 +153,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
154 | { | 153 | { |
155 | return "x86"; | 154 | return "x86"; |
156 | } | 155 | } |
156 | else if (IsNetFx1xAssembly(headers)) | ||
157 | { | ||
158 | // .NET Framework 1.x didn't support 64-bit, so if the assembly isn't explicitly 32-bit-required, | ||
159 | // the architecture wasn't specified, unlike .NET 2.0 and later, which identify it as MSIL. | ||
160 | return null; | ||
161 | } | ||
157 | else if ((headers.CorHeader.Flags & CorFlags.ILOnly) == CorFlags.ILOnly) | 162 | else if ((headers.CorHeader.Flags & CorFlags.ILOnly) == CorFlags.ILOnly) |
158 | { | 163 | { |
159 | return "MSIL"; | 164 | return "MSIL"; |
@@ -166,6 +171,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
166 | } | 171 | } |
167 | } | 172 | } |
168 | 173 | ||
174 | private static bool IsNetFx1xAssembly(PEHeaders headers) | ||
175 | { | ||
176 | return headers.CorHeader.MajorRuntimeVersion == 2 && headers.CorHeader.MinorRuntimeVersion == 0; | ||
177 | } | ||
178 | |||
169 | private static string ReadString(MetadataReader reader, StringHandle handle) | 179 | private static string ReadString(MetadataReader reader, StringHandle handle) |
170 | { | 180 | { |
171 | return handle.IsNil ? null : reader.GetString(handle); | 181 | return handle.IsNil ? null : reader.GetString(handle); |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs index 3bdfa0ef..ff241b50 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs | |||
@@ -596,6 +596,61 @@ namespace WixToolsetTest.CoreIntegration | |||
596 | } | 596 | } |
597 | 597 | ||
598 | [Fact] | 598 | [Fact] |
599 | public void CanBuildWithNet1xAssembly() | ||
600 | { | ||
601 | var folder = TestData.Get(@"TestData\Assembly1x"); | ||
602 | |||
603 | using (var fs = new DisposableFileSystem()) | ||
604 | { | ||
605 | var baseFolder = fs.GetFolder(); | ||
606 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
607 | |||
608 | var result = WixRunner.Execute(new[] | ||
609 | { | ||
610 | "build", | ||
611 | Path.Combine(folder, "Package.wxs"), | ||
612 | Path.Combine(folder, "PackageComponents.wxs"), | ||
613 | "-loc", Path.Combine(folder, "Package.en-us.wxl"), | ||
614 | "-bindpath", Path.Combine(folder, "data"), | ||
615 | "-intermediateFolder", intermediateFolder, | ||
616 | "-o", Path.Combine(baseFolder, @"bin\test.msi") | ||
617 | }); | ||
618 | |||
619 | result.AssertSuccess(); | ||
620 | |||
621 | Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.msi"))); | ||
622 | Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.wixpdb"))); | ||
623 | Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\PFiles\AssemblyMsiPackage\candle.exe"))); | ||
624 | |||
625 | var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"bin\test.wixpdb")); | ||
626 | var section = intermediate.Sections.Single(); | ||
627 | |||
628 | var fileSymbol = section.Symbols.OfType<FileSymbol>().Single(); | ||
629 | Assert.Equal(Path.Combine(folder, @"data\candle.exe"), fileSymbol[FileSymbolFields.Source].AsPath().Path); | ||
630 | Assert.Equal(@"candle.exe", fileSymbol[FileSymbolFields.Source].PreviousValue.AsPath().Path); | ||
631 | |||
632 | var msiAssemblyNameSymbols = section.Symbols.OfType<MsiAssemblyNameSymbol>(); | ||
633 | Assert.Equal(new[] | ||
634 | { | ||
635 | "culture", | ||
636 | "fileVersion", | ||
637 | "name", | ||
638 | "publicKeyToken", | ||
639 | "version" | ||
640 | }, msiAssemblyNameSymbols.OrderBy(a => a.Name).Select(a => a.Name).ToArray()); | ||
641 | |||
642 | Assert.Equal(new[] | ||
643 | { | ||
644 | "neutral", | ||
645 | "2.0.5805.0", | ||
646 | "candle", | ||
647 | "CE35F76FCDA82BAD", | ||
648 | "2.0.5805.0", | ||
649 | }, msiAssemblyNameSymbols.OrderBy(a => a.Name).Select(a => a.Value).ToArray()); | ||
650 | } | ||
651 | } | ||
652 | |||
653 | [Fact] | ||
599 | public void CanBuild64bit() | 654 | public void CanBuild64bit() |
600 | { | 655 | { |
601 | var folder = TestData.Get(@"TestData\SingleFile"); | 656 | var folder = TestData.Get(@"TestData\SingleFile"); |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Assembly1x/Package.en-us.wxl b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Assembly1x/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Assembly1x/Package.en-us.wxl | |||
@@ -0,0 +1,11 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | |||
3 | <!-- | ||
4 | This file contains the declaration of all the localizable strings. | ||
5 | --> | ||
6 | <WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US"> | ||
7 | |||
8 | <String Id="DowngradeError">A newer version of [ProductName] is already installed.</String> | ||
9 | <String Id="FeatureTitle">MsiPackage</String> | ||
10 | |||
11 | </WixLocalization> | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Assembly1x/Package.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Assembly1x/Package.wxs new file mode 100644 index 00000000..c345305d --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Assembly1x/Package.wxs | |||
@@ -0,0 +1,17 @@ | |||
1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
2 | <Package Name="AssemblyMsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" Compressed="no" InstallerVersion="200" Scope="perMachine"> | ||
3 | |||
4 | |||
5 | <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" /> | ||
6 | |||
7 | <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)"> | ||
8 | <ComponentGroupRef Id="ProductComponents" /> | ||
9 | </Feature> | ||
10 | </Package> | ||
11 | |||
12 | <Fragment> | ||
13 | <StandardDirectory Id="ProgramFilesFolder"> | ||
14 | <Directory Id="INSTALLFOLDER" Name="AssemblyMsiPackage" /> | ||
15 | </StandardDirectory> | ||
16 | </Fragment> | ||
17 | </Wix> | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Assembly1x/PackageComponents.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Assembly1x/PackageComponents.wxs new file mode 100644 index 00000000..e0c84c63 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Assembly1x/PackageComponents.wxs | |||
@@ -0,0 +1,10 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Fragment> | ||
4 | <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> | ||
5 | <Component> | ||
6 | <File Source="candle.exe" Assembly=".net" /> | ||
7 | </Component> | ||
8 | </ComponentGroup> | ||
9 | </Fragment> | ||
10 | </Wix> | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Assembly1x/data/candle.exe b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Assembly1x/data/candle.exe new file mode 100644 index 00000000..7a16cbab --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Assembly1x/data/candle.exe | |||
Binary files differ | |||