【发布时间】:2014-07-03 21:52:20
【问题描述】:
真的在为此苦苦挣扎。我尝试了各种不同的方法,但似乎没有任何效果。
-使用 addScript:我收到一条错误消息,告诉我不能以这种方式调用参数,而应该使用像 ISE 这样的 UI?!
-使用 FilePath 参数,我找不到传递参数的正确方法(绑定问题)
这是我尝试过的最新版本,没有错误,但是脚本没有执行,没有任何反应......
我们将不胜感激。
runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
pipeline = runspace.CreatePipeline();
string script =
@"{param($merchantName, $appType, $gruntDirectory, $merchantInstanceDirectory, $editorConnectionString) "+
_config.MerchantInstance.Directory + @"\Generate_And_Compile_LESS.ps1"
+ " –merchantName $merchantName"
+ " –appType $appType"
+ " –gruntDirectory $gruntDirectory"
+ " -merchantInstanceDirectory $merchantInstanceDirectory"
+ " -editorConnectionString $editorConnectionString }";
Command compileCommand = new Command("Invoke-Command");
compileCommand.Parameters.Add("Scriptblock", ScriptBlock.Create(script));
var args = new List<string>();
args.Add(merchantName);
args.Add(appType.GetHashCode().ToString());
args.Add("'" + _config.Grunt.Directory + "'");
args.Add("'" + _config.MerchantInstance.Directory + "'");
args.Add("'" + _connectionStrings.AppConnectionString + "'");
compileCommand.Parameters.Add("ArgumentList", String.Join(",", args));
pipeline.Commands.Add(compileCommand);
Collection<PSObject> results = pipeline.Invoke();
【问题讨论】:
标签: c# powershell