Open evil-shrike opened 6 years ago
The semicolon is a Powershell literal that you should be able to work around by escaping as such using the backtick ` character. Here is an example that works with Cake 0.21.1
> .\build.ps1 -target Run-Xunit-Tests IncludeTraits='Capability=netcore`;NodeType=Windows'
Tests will be run for: MyAssembly.dll
Including Traits: Capability=netcore;NodeType=Windows
Excluding Traits:
@kcamp Thanks! It helps. This works:
powershell ./build.ps1 -target Publish --publishTargets='internal1`,dev1' -channel=SNAPSHOT --settings_skipverification=true
Only with single quotes (not double).
@evil-shrike Yes, you're correct. I meant to call out the single/double difference because that threw me off, too when I was dealing with the issue. Glad you got it sorted out. 👍
I think the issue can be closed. But I'm afraid anyone who will try to pass such values (with "," or ";') will encounter difficulties. So ideally (in case it cannot be worked around in the bootstrap ps-script) it should be documented in some way...
Is it possible to have conditional invocation instead of conditional expression creation with Invoke-Expression? The last one causes real issues in case you want to pass servicePrincipalKey having multiple special characters, when working with Azure CLI. In # Start Cake
section, could we have something like:
Write-Host "Running build script..."
if ($IsLinux -or $IsMacOS) {
&mono $CAKE_EXE $cakeArguments
} else {
&$CAKE_EXE $cakeArguments
}
Sorry for my code, I'm not a PowerShell expert.
@piotrzajac probably yes, I think what most do is to pass sectets as environment variables.
Cake repos own bootstrapper does this, it doesn't use Mono though, but instead uses the Cake global tool, so diff between platforms there is executable name https://github.com/cake-build/cake/blob/06e798370487b61cad711904edf1adf7e772b70f/build.ps1#L148-L153
I have a cake script with Argument publishTargets:
I need to pass a value like "dev,internal" or "dev,release" and so on into it. The key point here is "," symbol. With ";" symbol there's the same picture.
What I tried:
1. via
-arg
Output:
2. via ScriptArgs
Output:
3. via
--arg
Output:
4. Running directly via cake.exe
It works.
Environment
Cake 0.22.2 OS x64 Windows 10