3

我正在尝试将以下 c# 控制台应用程序转换为 powershell 脚本。到目前为止,转换后的 power-shell 卡在 ExtractCabFiles 行上。我错过了转换后的代码中的任何内容吗?两者都已附加,因为我知道这可能会有所帮助。

这是控制台代码

  MethodInfo extractCab = typeof (SPSolutionLanguagePack).GetMethod("ExtractCabFiles",
                                    BindingFlags.Default |
                                    BindingFlags.Static |
                                    BindingFlags.NonPublic);

  //extract the wsp files to the temp folder
  extractCab.Invoke(null, newobject[] {Path.GetFullPath(filesFolder), Path.GetFullPath(solutionName)});

这是转换后的代码

MethodInfo $extractCab = typeof (SPSolutionLanguagePack).GetMethod("ExtractCabFiles",
                                    BindingFlags.Default |
                                    BindingFlags.Static |
                                    BindingFlags.NonPublic);

#extract the wsp files to the temp folder
$extractCab.Invoke(null, newobject[] {Path.GetFullPath($filesFolder), Path.GetFullPath($solutionName)});  
4

1 回答 1

0

您的 powershell 语法在某些地方不正确。你要这个:

# you will need to specify the FULL namespace-qualified type name for SPSolutionLanguagePack, I don't know what that is from your post
$extractCab = [SPSolutionLanguagePack].GetMethod("ExtractCabFiles", [Reflection.BindingFlags] 'Default, Static, NonPublic')

#extract the wsp files to the temp folder
$extractCab.Invoke($null, @( [IO.Path]::GetFullPath($filesFolder), [IO.Path]::GetFullPath($solutionName)))  
于 2012-09-05T17:24:15.040 回答