Skip to content

Commit 51bd366

Browse files
committed
Fix for /define acting like a switch instead of a parameter due to quoting
Issue #16 All 54 tests pass
1 parent 01010ec commit 51bd366

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
---
66

7+
## [0.5.0] - Unreleased
8+
9+
- Define parameter broken - MSBuild thinks it's a switch
10+
[#16](https://github.com/continuous-delphi/delphi-msbuild/issues/16)
11+
712
## [0.4.0] - 2026-03-17
813

914
- Ensure `PowerShell 5.1` compatibility for the delphi-msbuild.ps1 script

source/delphi-msbuild.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,14 @@ function Invoke-MsbuildProject {
213213
$msbuildArgs += "/p:DCC_UnitSearchPath=$unitSearchValue"
214214
}
215215

216+
if ($UnitSearchPath.Count -gt 0) {
217+
$unitSearchValue = '$(DCC_UnitSearchPath);' + ($UnitSearchPath -join ';')
218+
$msbuildArgs += "/p:DCC_UnitSearchPath=`"$unitSearchValue`""
219+
}
220+
216221
if ($Define.Count -gt 0) {
217222
$defineValue = '$(DCC_Define);' + ($Define -join ';')
218-
$msbuildArgs += "/p:DCC_Define=$defineValue"
223+
$msbuildArgs += "/p:DCC_Define=`"$defineValue`""
219224
}
220225

221226
return Invoke-MsbuildExe -Arguments $msbuildArgs -ShowOutput:$ShowOutput

tests/pwsh/delphi-msbuild.Tests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,8 @@ Describe 'Invoke-MsbuildProject' {
508508
-Define @('MYFLAG')
509509
}
510510

511-
It 'includes /p:DCC_Define=$(DCC_Define);MYFLAG' {
512-
$script:capturedArgs | Should -Contain '/p:DCC_Define=$(DCC_Define);MYFLAG'
511+
It 'includes /p:DCC_Define="$(DCC_Define);MYFLAG"' {
512+
$script:capturedArgs | Should -Contain '/p:DCC_Define="$(DCC_Define);MYFLAG"'
513513
}
514514

515515
}
@@ -532,8 +532,8 @@ Describe 'Invoke-MsbuildProject' {
532532
-Define @('MYFLAG', 'USE_JEDI_JCL')
533533
}
534534

535-
It 'includes /p:DCC_Define=$(DCC_Define);MYFLAG;USE_JEDI_JCL' {
536-
$script:capturedArgs | Should -Contain '/p:DCC_Define=$(DCC_Define);MYFLAG;USE_JEDI_JCL'
535+
It 'includes /p:DCC_Define="$(DCC_Define);MYFLAG;USE_JEDI_JCL"' {
536+
$script:capturedArgs | Should -Contain '/p:DCC_Define="$(DCC_Define);MYFLAG;USE_JEDI_JCL"'
537537
}
538538

539539
}

0 commit comments

Comments
 (0)