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

あなたのパワーシェル構文は、いくつかの場所で正しくありません。あなたはこれを求めている:

# 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 に答える