@@ -50,68 +50,83 @@ function Import-TestToolkitToNavContainer {
50
50
$doNotUpdateSymbols = $true
51
51
}
52
52
53
- $sqlCredential = Get-DefaultSqlCredential - containerName $containerName - sqlCredential $sqlCredential - doNotAskForCredential
54
-
55
- Invoke-ScriptInNavContainer - containerName $containerName - ScriptBlock { Param ([PSCredential ]$sqlCredential , $includeTestLibrariesOnly , $testToolkitCountry , $doNotUpdateSymbols , $ImportAction )
56
-
57
- if (-not (Test-Path - Path " C:\TestToolKit" - PathType Container)) {
58
- throw " Container $containerName does not include the TestToolkit yet"
53
+ if ($version.Major -ge 15 ) {
54
+ if ($version -lt [Version ](" 15.0.35528.0" )) {
55
+ throw " Container $containerName (platform version $version ) doesn't support the Test Toolkit yet, you need a laster version"
59
56
}
60
-
61
- $customConfigFile = Join-Path (Get-Item " C:\Program Files\Microsoft Dynamics NAV\*\Service" ).FullName " CustomSettings.config"
62
- [xml ]$customConfig = [System.IO.File ]::ReadAllText($customConfigFile )
63
- $databaseServer = $customConfig.SelectSingleNode (" //appSettings/add[@key='DatabaseServer']" ).Value
64
- $databaseInstance = $customConfig.SelectSingleNode (" //appSettings/add[@key='DatabaseInstance']" ).Value
65
- $databaseName = $customConfig.SelectSingleNode (" //appSettings/add[@key='DatabaseName']" ).Value
66
- $managementServicesPort = $customConfig.SelectSingleNode (" //appSettings/add[@key='ManagementServicesPort']" ).Value
67
- if ($databaseInstance ) { $databaseServer += " \$databaseInstance " }
68
-
69
- $params = @ {}
70
- if ($sqlCredential ) {
71
- $params = @ { ' Username' = $sqlCredential.UserName ; ' Password' = ([System.Runtime.InteropServices.Marshal ]::PtrToStringAuto([System.Runtime.InteropServices.Marshal ]::SecureStringToBSTR($sqlCredential.Password ))) }
57
+ if (! $includeTestLibrariesOnly ) {
58
+ Write-Warning " Importing Microsoft tests isn't yet supported, only test libraries will be imported"
72
59
}
73
- if ($testToolkitCountry ) {
74
- $fileFilter = " *.$testToolkitCountry .fob"
60
+
61
+ $appFiles = Invoke-ScriptInBCContainer - containerName $containerName - scriptblock {
62
+ " Microsoft_Any.app" , " Microsoft_Library Assert.app" , " Microsoft_Test Runner.app" | % {
63
+ @ (get-childitem - Path " C:\Applications\*.*" - recurse - filter $_ )
64
+ }
75
65
}
76
- else {
77
- $fileFilter = " *.fob "
66
+ $appFiles | % {
67
+ Publish-BCContainerApp - containerName $containerName - appFile " : $ ( $_ .FullName ) " - sync - install
78
68
}
79
- Get-ChildItem - Path " C:\TestToolKit" - Filter $fileFilter | ForEach-Object {
80
- if (! $includeTestLibrariesOnly -or $_.Name.StartsWith (" CALTestLibraries" )) {
81
- $objectsFile = $_.FullName
82
- Write-Host " Importing Objects from $objectsFile (container path)"
83
- $databaseServerParameter = $databaseServer
84
-
85
- if (! $doNotUpdateSymbols ) {
86
- Write-Host " Generating Symbols while importing"
87
- # HACK: Parameter insertion...
88
- # generatesymbolreference is not supported by Import-NAVApplicationObject yet
89
- # insert an extra parameter for the finsql command by splitting the filter property
90
- $databaseServerParameter = ' ",generatesymbolreference=1,ServerName="' + $databaseServer
69
+ Write-Host - ForegroundColor Green " TestToolkit successfully imported"
70
+ }
71
+ else {
72
+ $sqlCredential = Get-DefaultSqlCredential - containerName $containerName - sqlCredential $sqlCredential - doNotAskForCredential
73
+ Invoke-ScriptInNavContainer - containerName $containerName - ScriptBlock { Param ([PSCredential ]$sqlCredential , $includeTestLibrariesOnly , $testToolkitCountry , $doNotUpdateSymbols , $ImportAction )
74
+
75
+ $customConfigFile = Join-Path (Get-Item " C:\Program Files\Microsoft Dynamics NAV\*\Service" ).FullName " CustomSettings.config"
76
+ [xml ]$customConfig = [System.IO.File ]::ReadAllText($customConfigFile )
77
+ $databaseServer = $customConfig.SelectSingleNode (" //appSettings/add[@key='DatabaseServer']" ).Value
78
+ $databaseInstance = $customConfig.SelectSingleNode (" //appSettings/add[@key='DatabaseInstance']" ).Value
79
+ $databaseName = $customConfig.SelectSingleNode (" //appSettings/add[@key='DatabaseName']" ).Value
80
+ $managementServicesPort = $customConfig.SelectSingleNode (" //appSettings/add[@key='ManagementServicesPort']" ).Value
81
+ if ($databaseInstance ) { $databaseServer += " \$databaseInstance " }
82
+
83
+ $params = @ {}
84
+ if ($sqlCredential ) {
85
+ $params = @ { ' Username' = $sqlCredential.UserName ; ' Password' = ([System.Runtime.InteropServices.Marshal ]::PtrToStringAuto([System.Runtime.InteropServices.Marshal ]::SecureStringToBSTR($sqlCredential.Password ))) }
86
+ }
87
+ if ($testToolkitCountry ) {
88
+ $fileFilter = " *.$testToolkitCountry .fob"
89
+ }
90
+ else {
91
+ $fileFilter = " *.fob"
92
+ }
93
+ Get-ChildItem - Path " C:\TestToolKit" - Filter $fileFilter | ForEach-Object {
94
+ if (! $includeTestLibrariesOnly -or $_.Name.StartsWith (" CALTestLibraries" )) {
95
+ $objectsFile = $_.FullName
96
+ Write-Host " Importing Objects from $objectsFile (container path)"
97
+ $databaseServerParameter = $databaseServer
98
+
99
+ if (! $doNotUpdateSymbols ) {
100
+ Write-Host " Generating Symbols while importing"
101
+ # HACK: Parameter insertion...
102
+ # generatesymbolreference is not supported by Import-NAVApplicationObject yet
103
+ # insert an extra parameter for the finsql command by splitting the filter property
104
+ $databaseServerParameter = ' ",generatesymbolreference=1,ServerName="' + $databaseServer
105
+ }
106
+
107
+ Import-NAVApplicationObject @params - Path $objectsFile `
108
+ - DatabaseName $databaseName `
109
+ - DatabaseServer $databaseServerParameter `
110
+ - ImportAction $ImportAction `
111
+ - SynchronizeSchemaChanges No `
112
+ - NavServerName localhost `
113
+ - NavServerInstance $ServerInstance `
114
+ - NavServerManagementPort " $managementServicesPort " `
115
+ - Confirm:$false
116
+
91
117
}
118
+ }
92
119
93
- Import-NAVApplicationObject @params - Path $objectsFile `
94
- - DatabaseName $databaseName `
95
- - DatabaseServer $databaseServerParameter `
96
- - ImportAction $ImportAction `
97
- - SynchronizeSchemaChanges No `
98
- - NavServerName localhost `
99
- - NavServerInstance $ServerInstance `
100
- - NavServerManagementPort " $managementServicesPort " `
101
- - Confirm:$false
120
+ # Sync after all objects hav been imported
121
+ Get-NAVTenant - ServerInstance $ServerInstance | Sync-NavTenant - Mode ForceSync - Force
102
122
103
- }
123
+ } - ArgumentList $sqlCredential , $includeTestLibrariesOnly , $testToolkitCountry , $doNotUpdateSymbols , $ImportAction
124
+
125
+ if ($generateSymbols ) {
126
+ Generate- SymbolsInNavContainer - containerName $containerName - sqlCredential $sqlCredential
104
127
}
105
-
106
- # Sync after all objects hav been imported
107
- Get-NAVTenant - ServerInstance $ServerInstance | Sync-NavTenant - Mode ForceSync - Force
108
-
109
- } - ArgumentList $sqlCredential , $includeTestLibrariesOnly , $testToolkitCountry , $doNotUpdateSymbols , $ImportAction
110
-
111
- if ($generateSymbols ) {
112
- Generate- SymbolsInNavContainer - containerName $containerName - sqlCredential $sqlCredential
128
+ Write-Host - ForegroundColor Green " TestToolkit successfully imported"
113
129
}
114
- Write-Host - ForegroundColor Green " TestToolkit successfully imported"
115
130
}
116
131
Set-Alias - Name Import-TestToolkitToBCContainer - Value Import-TestToolkitToNavContainer
117
132
Export-ModuleMember - Function Import-TestToolkitToNavContainer - Alias Import-TestToolkitToBCContainer
0 commit comments