|
26 | 26 | Passes correct MSBuild arguments to Invoke-MsbuildExe. |
27 | 27 | Forwards -ShowOutput switch to Invoke-MsbuildExe. |
28 | 28 | Returns the result object from Invoke-MsbuildExe. |
| 29 | + Omits /p:DCC_Define when no defines are supplied. |
| 30 | + Appends /p:DCC_Define with $(DCC_Define) prefix for a single define. |
| 31 | + Appends /p:DCC_Define with $(DCC_Define) prefix for multiple defines. |
29 | 32 |
|
30 | 33 | Describe 5 - Main flow (via Invoke-ToolProcess, no MSBuild calls): |
31 | 34 | Exits 3 when no rootDir is provided (no pipeline, no -RootDir). |
@@ -293,6 +296,78 @@ Describe 'Invoke-MsbuildProject' { |
293 | 296 |
|
294 | 297 | } |
295 | 298 |
|
| 299 | + Context 'omits /p:DCC_Define when no -Define values are supplied' { |
| 300 | + |
| 301 | + BeforeAll { |
| 302 | + $script:capturedArgs = $null |
| 303 | + Mock Invoke-MsbuildExe { |
| 304 | + $script:capturedArgs = $Arguments |
| 305 | + return [pscustomobject]@{ ExitCode = 0; Output = '' } |
| 306 | + } |
| 307 | + |
| 308 | + Invoke-MsbuildProject ` |
| 309 | + -ProjectFile 'C:\Projects\MyApp.dproj' ` |
| 310 | + -Platform 'Win32' ` |
| 311 | + -Config 'Debug' ` |
| 312 | + -Target 'Build' ` |
| 313 | + -Verbosity 'normal' |
| 314 | + } |
| 315 | + |
| 316 | + It 'does not include any /p:DCC_Define argument' { |
| 317 | + $script:capturedArgs | Should -Not -Contain { $_ -like '/p:DCC_Define=*' } |
| 318 | + ($script:capturedArgs | Where-Object { $_ -like '/p:DCC_Define=*' }) | Should -BeNullOrEmpty |
| 319 | + } |
| 320 | + |
| 321 | + } |
| 322 | + |
| 323 | + Context 'appends /p:DCC_Define with $(DCC_Define) prefix for a single define' { |
| 324 | + |
| 325 | + BeforeAll { |
| 326 | + $script:capturedArgs = $null |
| 327 | + Mock Invoke-MsbuildExe { |
| 328 | + $script:capturedArgs = $Arguments |
| 329 | + return [pscustomobject]@{ ExitCode = 0; Output = '' } |
| 330 | + } |
| 331 | + |
| 332 | + Invoke-MsbuildProject ` |
| 333 | + -ProjectFile 'C:\Projects\MyApp.dproj' ` |
| 334 | + -Platform 'Win32' ` |
| 335 | + -Config 'Debug' ` |
| 336 | + -Target 'Build' ` |
| 337 | + -Verbosity 'normal' ` |
| 338 | + -Define @('MYFLAG') |
| 339 | + } |
| 340 | + |
| 341 | + It 'includes /p:DCC_Define=$(DCC_Define);MYFLAG' { |
| 342 | + $script:capturedArgs | Should -Contain '/p:DCC_Define=$(DCC_Define);MYFLAG' |
| 343 | + } |
| 344 | + |
| 345 | + } |
| 346 | + |
| 347 | + Context 'appends /p:DCC_Define with $(DCC_Define) prefix for multiple defines' { |
| 348 | + |
| 349 | + BeforeAll { |
| 350 | + $script:capturedArgs = $null |
| 351 | + Mock Invoke-MsbuildExe { |
| 352 | + $script:capturedArgs = $Arguments |
| 353 | + return [pscustomobject]@{ ExitCode = 0; Output = '' } |
| 354 | + } |
| 355 | + |
| 356 | + Invoke-MsbuildProject ` |
| 357 | + -ProjectFile 'C:\Projects\MyApp.dproj' ` |
| 358 | + -Platform 'Win32' ` |
| 359 | + -Config 'Debug' ` |
| 360 | + -Target 'Build' ` |
| 361 | + -Verbosity 'normal' ` |
| 362 | + -Define @('MYFLAG', 'USE_JEDI_JCL') |
| 363 | + } |
| 364 | + |
| 365 | + It 'includes /p:DCC_Define=$(DCC_Define);MYFLAG;USE_JEDI_JCL' { |
| 366 | + $script:capturedArgs | Should -Contain '/p:DCC_Define=$(DCC_Define);MYFLAG;USE_JEDI_JCL' |
| 367 | + } |
| 368 | + |
| 369 | + } |
| 370 | + |
296 | 371 | } |
297 | 372 |
|
298 | 373 | Describe 'Main flow -- pre-MSBuild validation (no MSBuild invoked)' { |
|
0 commit comments