forked from myob-oss/AccountRight_Live_API_.Net_SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdk.project.check.ps1
66 lines (58 loc) · 2.91 KB
/
sdk.project.check.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#this checks that the target project has the same set of compile includes as the master file used for testing
function Check-Same-Compile-Includes {
param([string] $srcfile, [string] $targetfile)
Write-Host "Comparing the compile includes of $srcfile against $targetfile"
$srcxml = [xml](gc $srcfile)
$targetxml = [xml](gc $targetfile)
$ns = @{'e'="http://schemas.microsoft.com/developer/msbuild/2003" }
@(Select-Xml '//e:Compile' $srcxml -Namespace $ns) |
select -ExpandProperty Node |
? { $_.Include} |
select -ExpandProperty Include | where { $_ -ne 'Properties\AssemblyInfoEx.cs' } |
% {
$compile = $_
@(Select-Xml "//e:Compile[@Include = '..\SDK\$_']" $targetxml -Namespace $ns) | Measure-Object |
% {
if ($_.Count -ne 1) {
Write-Host "The file '$compile' is missing from the project $targetfile. Please include and try again..."
throw [System.InvalidOperationException] "The file '$compile' is missing from the project $targetfile. Please include and try again..."
}
}
}
}
function Check-Same-Compile-Includes-Back {
param([string] $srcfile, [string] $targetfile)
Write-Host "Comparing the compile includes of $srcfile against $targetfile"
$srcxml = [xml](gc $srcfile)
$targetxml = [xml](gc $targetfile)
$ns = @{'e'="http://schemas.microsoft.com/developer/msbuild/2003" }
@(Select-Xml '//e:Link' $srcxml -Namespace $ns) |
select -ExpandProperty Node |
? { $_.Include} |
select -ExpandProperty Include | where { $_ -ne 'Properties\AssemblyInfoEx.cs' } |
% {
$compile = $_
@(Select-Xml "//e:Compile[@Include = '$_']" $targetxml -Namespace $ns) | Measure-Object |
% {
if ($_.Count -ne 1) {
Write-Host "The file '$compile' is missing from the project $targetfile. Please include and try again..."
throw [System.InvalidOperationException] "The file '$compile' is missing from the project $targetfile. Please include and try again..."
}
}
}
}
try
{
#check each of the project files against SDK.proj (i.e. all A in B and all B in A)
Check-Same-Compile-Includes -srcfile '.\MYOB.API.SDK\SDK\SDK.csproj' -targetfile '.\MYOB.API.SDK\SDK.NET35\SDK.NET35.csproj'
Check-Same-Compile-Includes-Back -srcfile '.\MYOB.API.SDK\SDK.NET35\SDK.NET35.csproj' -targetfile '.\MYOB.API.SDK\SDK\SDK.csproj'
Check-Same-Compile-Includes -srcfile '.\MYOB.API.SDK\SDK\SDK.csproj' -targetfile '.\MYOB.API.SDK\SDK.NET40\SDK.NET40.csproj'
Check-Same-Compile-Includes-Back -srcfile '.\MYOB.API.SDK\SDK.NET40\SDK.NET40.csproj' -targetfile '.\MYOB.API.SDK\SDK\SDK.csproj'
Check-Same-Compile-Includes -srcfile '.\MYOB.API.SDK\SDK\SDK.csproj' -targetfile '.\MYOB.API.SDK\SDK.NET45\SDK.NET45.csproj'
Check-Same-Compile-Includes-Back -srcfile '.\MYOB.API.SDK\SDK.NET45\SDK.NET45.csproj' -targetfile '.\MYOB.API.SDK\SDK\SDK.csproj'
}
catch [System.Exception]
{
Write-Error $_.Message
Exit 1
}