diff --git a/ps12exe.ps1 b/ps12exe.ps1 index da8faa88..ec3e0edc 100644 --- a/ps12exe.ps1 +++ b/ps12exe.ps1 @@ -472,6 +472,9 @@ if ($SyntaxErrors) { $global:LastExitCode = 1 return } +elseif (!$AST) { + $AST = [System.Management.Automation.Language.Parser]::ParseInput($Content, [ref]$null, [ref]$null) +} # retrieve absolute paths independent if path is given relative oder absolute if (-not $inputFile) { @@ -566,6 +569,19 @@ $resourceParamKeys | ForEach-Object { } } +if ($AST.ParamBlock) { + $hasCmdletBinding = $false + foreach ($param in $AST.ParamBlock.Attributes) { + if ($param.TypeName.Name -eq 'CmdletBinding') { + $hasCmdletBinding = $true + break + } + } + if (!$hasCmdletBinding) { + Write-I18n Warning TopLevelNoCmdletBindingFound + } +} + . $PSScriptRoot\src\AstAnalyze.ps1 $AstAnalyzeResult = AstAnalyze $Ast Write-Debug "AstAnalyzeResult: $(($AstAnalyzeResult|ConvertTo-Json) -split "\r?\n" -ne '' -join "`n")" diff --git a/src/locale/en-UK.ps1 b/src/locale/en-UK.ps1 index 84c70455..40b23bba 100644 --- a/src/locale/en-UK.ps1 +++ b/src/locale/en-UK.ps1 @@ -127,6 +127,7 @@ SomeCmdletsMayNotAvailable = "Cmdlets {0} used but may not available in runtime, make sure you've checked it!" SomeNotFindedCmdlets = "Unknown functions {0} used" SomeTypesMayNotAvailable = "Types {0} used but may not available in runtime, make sure you've checked it!" + TopLevelNoCmdletBindingFound = "The program has a parameter block, but the parameter block does not have the CmdletBinding attribute. This may cause the final program to be unable to receive parameters." CompilingFile = "Compiling file..." CompilationFailed = "Compilation failed!" OutputFileNotWritten = "Output file {0} not written" diff --git a/src/locale/es-ES.ps1 b/src/locale/es-ES.ps1 index b404d6c5..7df657fd 100644 --- a/src/locale/es-ES.ps1 +++ b/src/locale/es-ES.ps1 @@ -127,6 +127,7 @@ SomeCmdletsMayNotAvailable = "¡Se usaron cmdlets {0} pero pueden no estar disponibles en tiempo de ejecución, asegúrese de haberlos verificado!" SomeNotFindedCmdlets = "Se usaron funciones desconocidas {0}" SomeTypesMayNotAvailable = "¡Se usaron tipos {0} pero pueden no estar disponibles en tiempo de ejecución, asegúrese de haberlos verificado!" + TopLevelNoCmdletBindingFound = "El programa tiene un bloque de parámetros, pero el bloque de parámetros no tiene el atributo CmdletBinding. Esto puede hacer que el programa final no pueda recibir parámetros." CompilingFile = "Compilando archivo..." CompilationFailed = "¡Falló la compilación!" OutputFileNotWritten = "No se escribió el archivo de salida {0}" diff --git a/src/locale/hi-IN.ps1 b/src/locale/hi-IN.ps1 index 6a6da711..8c5f7283 100644 --- a/src/locale/hi-IN.ps1 +++ b/src/locale/hi-IN.ps1 @@ -127,6 +127,7 @@ SomeCmdletsMayNotAvailable = "उपयोग किए गए Cmdlets {0} लेकिन रनटाइम में उपलब्ध नहीं हो सकते हैं, सुनिश्चित करें कि आपने उनकी जांच की है!" SomeNotFindedCmdlets = "अज्ञात कार्यों {0} का उपयोग किया गया" SomeTypesMayNotAvailable = "उपयोग किए गए टाइप {0} रनटाइम में उपलब्ध नहीं हो सकते हैं, सुनिश्चित करें कि आपने उनकी जांच की है!" + TopLevelNoCmdletBindingFound = "इस प्रोग्राम में एक पैरामीटर ब्लॉक है, लेकिन पैरामीटर ब्लॉक में CmdletBinding विशेषता नहीं है। इससे अंतिम प्रोग्राम पैरामीटर प्राप्त करने में असमर्थ हो सकता है।" CompilingFile = "संकलन..." CompilationFailed = "संकलन विफल!" OutputFileNotWritten = "आउटपुट फ़ाइल {0} नहीं लिखी गई" diff --git a/src/locale/ja-JP.ps1 b/src/locale/ja-JP.ps1 index d33b3e8c..54cbd0bc 100644 --- a/src/locale/ja-JP.ps1 +++ b/src/locale/ja-JP.ps1 @@ -127,6 +127,7 @@ SomeCmdletsMayNotAvailable = "実行時に利用できない可能性のあるコマンドレット {0} が使用されています。確認してください!" SomeNotFindedCmdlets = "未知の命令 {0} が使用されています" SomeTypesMayNotAvailable = "実行時に利用できない可能性のある型 {0} が使用されています。確認してください!" + TopLevelNoCmdletBindingFound = "このプログラムにはパラメータブロックがありますが、パラメータブロックにCmdletBinding属性がありません。そのため、完成したプログラムがパラメータを受け取れなくなる可能性があります。" CompilingFile = "コンパイル中..." CompilationFailed = "コンパイルに失敗しました!" OutputFileNotWritten = "出力ファイル {0} が書き込まれませんでした" diff --git a/src/locale/zh-CN.ps1 b/src/locale/zh-CN.ps1 index 5dd6bd0c..8bf90464 100644 --- a/src/locale/zh-CN.ps1 +++ b/src/locale/zh-CN.ps1 @@ -127,6 +127,7 @@ SomeCmdletsMayNotAvailable = "使用了可能会在运行时不可用的命令 {0},确保已检查它们!" SomeNotFindedCmdlets = "使用了未知的命令 {0}" SomeTypesMayNotAvailable = "使用了可能会在运行时不可用的类型 {0},确保已检查它们!" + TopLevelNoCmdletBindingFound = "该程序有参数块,但参数块没有CmdletBinding属性,这可能导致成品程序无法接收参数。" CompilingFile = "编译中..." CompilationFailed = "编译失败!" OutputFileNotWritten = "未写入输出文件 {0}"