Skip to content

Commit 97b5453

Browse files
committed
Merge pull request #7 from heaths/develop
Output full MD5 hash for MSIHashParts
2 parents 5f8e940 + 641a303 commit 97b5453

File tree

12 files changed

+79
-16
lines changed

12 files changed

+79
-16
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
*.cache
2+
*.db
3+
*.log
24
*.ncb
35
*.nupkg
46
*.pdb
57
*.suo
68
*.user
79
*.vssscc
10+
.vs/
811
[Bb]in/
912
[Oo]bj/
10-
[Tt]humbs.db
1113
[Tt]est[Rr]esults/
1214
node_modules/
1315
packages/

GitVersionConfig.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
assembly-versioning-scheme: MajorMinorPatch
2-
next-version: 3.0.0
2+
next-version: 3.1.0

Psmsi.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.30110.0
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25123.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Setup", "Setup", "{FFCC062A-C705-4E55-A362-B206FB0B29BF}"
77
EndProject

src/PowerShell/FileHash.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
2222

23+
using System;
2324
using System.Collections.Generic;
25+
using System.Linq;
2426
using System.Runtime.InteropServices;
27+
using System.Text;
2528

2629
namespace Microsoft.Tools.WindowsInstaller
2730
{
@@ -50,6 +53,26 @@ internal FileHash()
5053
this.dwFileHashInfoSie = Marshal.SizeOf(this);
5154
}
5255

56+
/// <summary>
57+
/// Gets the MD5 hash value combining all parts.
58+
/// </summary>
59+
public string MSIHash
60+
{
61+
get
62+
{
63+
var parts = new[]
64+
{
65+
this.dwData0,
66+
this.dwData1,
67+
this.dwData2,
68+
this.dwData3,
69+
};
70+
71+
var buffer = parts.SelectMany(part => BitConverter.GetBytes(part));
72+
return buffer.Aggregate(new StringBuilder(32), (sb, b) => sb.Append(b.ToString("X2"))).ToString();
73+
}
74+
}
75+
5376
/// <summary>
5477
/// Gets the first hash part.
5578
/// </summary>
@@ -88,8 +111,7 @@ public int MSIHashPart4
88111
/// <returns>An enumerator over the four nullable integer hash parts.</returns>
89112
public IEnumerator<int> GetEnumerator()
90113
{
91-
var list = new List<int>() { this.MSIHashPart1, this.MSIHashPart2, this.MSIHashPart3, this.MSIHashPart4 };
92-
return list.GetEnumerator();
114+
return new[] { this.dwData0, this.dwData1, this.dwData2, this.dwData3 }.AsEnumerable().GetEnumerator();
93115
}
94116

95117
/// <summary>

src/PowerShell/MSI.types.ps1xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,19 @@
1212
<PropertySet>
1313
<Name>MSIFileHash</Name>
1414
<ReferencedProperties>
15+
<Name>MSIHash</Name>
1516
<Name>MSIHashPart1</Name>
1617
<Name>MSIHashPart2</Name>
1718
<Name>MSIHashPart3</Name>
1819
<Name>MSIHashPart4</Name>
1920
</ReferencedProperties>
2021
</PropertySet>
22+
<ScriptProperty>
23+
<Name>MSIHash</Name>
24+
<GetScriptBlock>
25+
$null
26+
</GetScriptBlock>
27+
</ScriptProperty>
2128
<ScriptProperty>
2229
<Name>MSIHashPart1</Name>
2330
<GetScriptBlock>
@@ -61,6 +68,12 @@
6168
<MethodName>GetFileHash</MethodName>
6269
</GetCodeReference>
6370
</CodeProperty>
71+
<ScriptProperty>
72+
<Name>MSIHash</Name>
73+
<GetScriptBlock>
74+
$this.MSIFileHash.MSIHash
75+
</GetScriptBlock>
76+
</ScriptProperty>
6477
<ScriptProperty>
6578
<Name>MSIHashPart1</Name>
6679
<GetScriptBlock>

src/PowerShell/PowerShell.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
<Import Project="$(IncludeDir)Common.targets" />
188188
<Import Project="$(IncludeDir)TextTemplating.targets" />
189189
<Import Project="$(SolutionDir).nuget\NuGet.targets" />
190-
<Target Name="CalculateVersion" AfterTargets="UpdateAssemblyInfo">
190+
<Target Name="CalculateVersion" DependsOnTargets="GetVersion" AfterTargets="UpdateAssemblyInfo">
191191
<PropertyGroup>
192192
<BuildNumber>$(GitVersion_BuildMetaData)</BuildNumber>
193193
<BuildNumber Condition="'$(BuildNumber)'==''">0</BuildNumber>
@@ -214,8 +214,8 @@
214214
<PropertyGroup>
215215
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
216216
</PropertyGroup>
217-
<Error Condition="!Exists('..\..\packages\GitVersionTask.3.3.0\build\portable-net+sl+win+wpa+wp\GitVersionTask.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\GitVersionTask.3.3.0\build\portable-net+sl+win+wpa+wp\GitVersionTask.targets'))" />
217+
<Error Condition="!Exists('..\..\packages\GitVersionTask.3.4.1\build\portable-net+sl+win+wpa+wp\GitVersionTask.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\GitVersionTask.3.4.1\build\portable-net+sl+win+wpa+wp\GitVersionTask.targets'))" />
218218
</Target>
219-
<Import Project="..\..\packages\GitVersionTask.3.3.0\build\portable-net+sl+win+wpa+wp\GitVersionTask.targets" Condition="Exists('..\..\packages\GitVersionTask.3.3.0\build\portable-net+sl+win+wpa+wp\GitVersionTask.targets')" />
219+
<Import Project="..\..\packages\GitVersionTask.3.4.1\build\portable-net+sl+win+wpa+wp\GitVersionTask.targets" Condition="Exists('..\..\packages\GitVersionTask.3.4.1\build\portable-net+sl+win+wpa+wp\GitVersionTask.targets')" />
220220
<!-- vim: set sw=2 ts=2 sts=2 ft=xml: -->
221221
</Project>

src/PowerShell/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="GitVersionTask" version="3.3.0" targetFramework="net4" developmentDependency="true" />
4-
</packages>
3+
<package id="GitVersionTask" version="3.4.1" targetFramework="net40" developmentDependency="true" />
4+
</packages>

test/PowerShell.Test/ActionTextTests.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
1+
// The MIT License (MIT)
2+
//
3+
// Copyright (c) Microsoft Corporation
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in all
13+
// copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
// SOFTWARE.
22+
23+
using Microsoft.VisualStudio.TestTools.UnitTesting;
224

325
namespace Microsoft.Tools.WindowsInstaller
426
{

test/PowerShell.Test/PowerShell.Test.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@
133133
<None Include="packages.config" />
134134
</ItemGroup>
135135
<Import Project="$(IncludeDir)Common.targets" />
136-
<Import Project="..\..\packages\GitVersionTask.3.3.0\build\dotnet\GitVersionTask.targets" Condition="Exists('..\..\packages\GitVersionTask.3.3.0\build\dotnet\GitVersionTask.targets')" />
137136
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
138137
<PropertyGroup>
139138
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
140139
</PropertyGroup>
141-
<Error Condition="!Exists('..\..\packages\GitVersionTask.3.3.0\build\dotnet\GitVersionTask.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\GitVersionTask.3.3.0\build\dotnet\GitVersionTask.targets'))" />
140+
<Error Condition="!Exists('..\..\packages\GitVersionTask.3.4.1\build\dotnet\GitVersionTask.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\GitVersionTask.3.4.1\build\dotnet\GitVersionTask.targets'))" />
142141
</Target>
142+
<Import Project="..\..\packages\GitVersionTask.3.4.1\build\dotnet\GitVersionTask.targets" Condition="Exists('..\..\packages\GitVersionTask.3.4.1\build\dotnet\GitVersionTask.targets')" />
143143
<!-- vim: set sw=2 ts=2 sts=2 ft=xml: -->
144-
</Project>
144+
</Project>

test/PowerShell.Test/PowerShell/Commands/GetFileHashCommandTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public void PathTest()
4747

4848
var obj = objs.Where(o => o.GetPropertyValue<int>("MSIHashPart1") == hash[0]).FirstOrDefault();
4949
Assert.IsNotNull(obj);
50+
Assert.AreEqual("823F806C8E20FC8A41A8FAAEA5999F00", obj.GetPropertyValue<string>("MSIHash"));
5051
Assert.AreEqual<int>(hash[0], obj.GetPropertyValue<int>("MSIHashPart1"));
5152
Assert.AreEqual<int>(hash[1], obj.GetPropertyValue<int>("MSIHashPart2"));
5253
Assert.AreEqual<int>(hash[2], obj.GetPropertyValue<int>("MSIHashPart3"));
@@ -78,6 +79,7 @@ select PSObject.AsPSObject(i)
7879

7980
Assert.AreEqual<int>(1, objs.Count);
8081
Assert.IsInstanceOfType(objs[0].BaseObject, typeof(System.IO.FileInfo));
82+
Assert.AreEqual<PSObject>("823F806C8E20FC8A41A8FAAEA5999F00", objs[0].GetPropertyValue<PSObject>("MSIHash"));
8183
Assert.AreEqual<PSObject>(hash[0], objs[0].GetPropertyValue<PSObject>("MSIHashPart1"));
8284
Assert.AreEqual<PSObject>(hash[1], objs[0].GetPropertyValue<PSObject>("MSIHashPart2"));
8385
Assert.AreEqual<PSObject>(hash[2], objs[0].GetPropertyValue<PSObject>("MSIHashPart3"));
@@ -90,6 +92,7 @@ select PSObject.AsPSObject(i)
9092
var objs = p.Invoke();
9193

9294
Assert.AreEqual<int>(1, objs.Count);
95+
Assert.IsNull(objs[0].Properties["MSIHash"].Value);
9396
Assert.IsNull(objs[0].Properties["MSIHashPart1"].Value);
9497
Assert.IsNull(objs[0].Properties["MSIHashPart2"].Value);
9598
Assert.IsNull(objs[0].Properties["MSIHashPart3"].Value);

0 commit comments

Comments
 (0)