cake: Exception when using ScripArgs with >1 param in powershell

What You Are Seeing?

In the windows command line:

>powershell -File test.ps1 -ScriptArgs '-param1="val1" -param2="val2"'

E:\svn-hydrique\DbManager\build_tmp\test.ps1 : A parameter cannot be found that matches parameter name ‘param2=val2’'. + CategoryInfo : InvalidArgument: (😃 [test.ps1], ParentContainsErrorRecordException + FullyQualifiedErrorId : NamedParameterNotFound,test.ps1

What is Expected?

This part of the code should be reached in test.cake (it is not even built after the previous error):

var invalidArgumentStr = "INVALID";
var val1 = Argument("param1", invalidArgumentStr);
var val2 = Argument("param2", invalidArgumentStr);

What version of Cake are you using?

<package id="Cake" version="0.20.0" />

Are you running on a 32 or 64 bit system?

64 bit system

What environment are you running on? Windows? Linux? Mac?

Windows

Are you running on a CI Server? If so, which one?

No

How Did You Get This To Happen? (Steps to Reproduce)

.Bat file:

powershell -File test.ps1 -ScriptArgs '-param1="val1" -param2="val2"'
PAUSE

.Cake file:

// ===
// USAGE:
// powershell -File test.ps1 -ScriptArgs '-param1="val1" -param2="val2"'

// ===
// CONFIGURATION:

var invalidArgumentStr = "INVALID";
var val1 = Argument("param1", invalidArgumentStr);
var val2 = Argument("param2", invalidArgumentStr);

// ===
// SCRIPT:

var target = Argument("target", "Default");

Task("Publish")
	.Does(() =>
	{    
		// do nothing
	});

Task("Default")
	.IsDependentOn("Publish");

RunTarget(target);

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 19 (8 by maintainers)

Most upvoted comments

Shouldn’t parameters in PowerShell be separated by a comma? .\test.ps1 -ScriptArgs '-param1-"val1"', '-param2="val2"'