Command
Build-PowerShellArtifact
Builds a packaged executable, typed CLR library, or importable binary/hybrid module from PowerShell source.
Syntax
Build-PowerShellArtifact
[-AllowUnreviewedDependencies]
[-BuildCacheDirectory <String>]
[-CertificateStoreLocation <CurrentUser| LocalMachine>]
[-CertificateThumbprint <String>]
[-DependencyLock <PowerShellCompilationDependencyGraph>]
[-EmitIrSnapshots]
[-EmitSource]
[-EntryPoint <String>]
[-ExcludeResource <String[]>]
[-ExpectedPublicAbiSha256 <String>]
[-IncludeResource <String[]>]
[-KeepBuildWorkspace]
[-Kind <Executable| Library| BinaryModule>]
[-Mode <Analyze| Package| Hybrid| Strict>]
[-Name <String>]
[-Optimization <Trimmed| NativeAot>]
[-OutputDirectory <String>]
[-Path] <String[]>
[-ResourceMode <Declared| CompleteModule>]
[-RuntimeIdentifier <String>]
[-SelfContained]
[-SignArtifact]
[-SigningTimeoutSeconds <Int32>]
[-SingleFile <Boolean>]
[-TargetContract <PowerShellCompilationTargetContract>]
[-TargetFramework <String>]
[-TimeoutSeconds <Int32>]
[-TimeStampServer <String>]
[-UseBuildCache <Boolean>]
[<CommonParameters>]#Parameter set:
All Parameter SetsExamples
Build a module from a separately reviewed dependency graph
$lock = (powerforge powershell analyze .\MyModule --output json | ConvertFrom-Json).result.dependencyGraph; Build-PowerShellArtifact -Path .\MyModule -EmitSource -DependencyLock $lockPackage a standalone script as a single-file executable
Build-PowerShellArtifact -Path .\tool.ps1 -AllowUnreviewedDependenciesCompile several loose scripts into one typed cmdlet module
Build-PowerShellArtifact -Path .\Public\Get-One.ps1, .\Public\Get-Two.ps1 -Kind BinaryModule -AllowUnreviewedDependenciesParameters
- -AllowUnreviewedDependencies SwitchParameter
- Explicitly allow a development build to resolve dependencies without a separately reviewed lock.
- -BuildCacheDirectory String
- Optional machine-local content-addressed build-cache root.
- -CertificateStoreLocation CertificateStoreLocation
- Certificate store used for Authenticode signing.
- Possible values:
CurrentUser,LocalMachine - -CertificateThumbprint String
- Optional code-signing certificate thumbprint.
- -DependencyLock PowerShellCompilationDependencyGraph
- Dependency graph produced by analysis and reviewed before this build.
- -EmitIrSnapshots SwitchParameter
- Publish a redacted semantic-only bound/lowered IR snapshot beside canonical evidence.
- -EmitSource SwitchParameter
- Publish an independently buildable generated C# source project beside the artifact.
- -EntryPoint String
- Explicit root .ps1 application entrypoint when several script paths are supplied for an executable.
- -ExcludeResource String[]
- Contained resource paths or glob patterns to exclude from optional payload.
- -ExpectedPublicAbiSha256 String
- Reviewed public ABI SHA-256 that the generated artifact must match.
- -IncludeResource String[]
- Contained resource paths or glob patterns to include beside the artifact.
- -KeepBuildWorkspace SwitchParameter
- Retain the generated project workspace for inspection.
- -Kind PowerShellCompilationArtifactKind
- Optional artifact shape. Defaults to Executable for .ps1 and BinaryModule for module inputs.
- Possible values:
Executable,Library,BinaryModule - -Mode PowerShellCompilationMode
- Fallback policy. Defaults to Package for executables and Hybrid for module/library inputs. Analyze is not a build mode.
- Possible values:
Analyze,Package,Hybrid,Strict - -Name String
- Artifact file and assembly name. Defaults to the source file name.
- -Optimization PowerShellCompilationExecutableOptimization
- Optional trimmed or native-AOT publication for a Strict typed executable.
- Possible values:
Trimmed,NativeAot - -OutputDirectory String
- Destination for durable artifacts and the compilation manifest.
- -Path String[]
- One PowerShell script/module path, or several loose .ps1 files for a typed library or strict binary module.
- -ResourceMode PowerShellCompilationResourceMode
- Optional payload policy. Declared includes manifest, explicit, and safely inferred resources.
- Possible values:
Declared,CompleteModule - -RuntimeIdentifier String
- Optional runtime identifier used when publishing an executable.
- -SelfContained SwitchParameter
- Include the .NET runtime when publishing an executable.
- -SignArtifact SwitchParameter
- Authenticode-sign generated signable files before integrity hashes are recorded.
- -SigningTimeoutSeconds Int32
- Maximum time allowed for Authenticode signing.
- -SingleFile Boolean
- Publish an executable as one file.
- -TargetContract PowerShellCompilationTargetContract
- Explicit semantic, execution, and deployment target. Its kind and mode must match the resolved input.
- -TargetFramework String
- Generated .NET target framework.
- -TimeoutSeconds Int32
- Maximum restore and compile time in seconds.
- -TimeStampServer String
- RFC3161 timestamp service used for Authenticode signing.
- -UseBuildCache Boolean
- Use the verified content-addressed generated-build cache.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.