PowerShell Pro Tools
Ironman SoftwareGitHub
  • About
  • System Requirements
  • PowerShell Tools Documentation
    • Visual Studio
      • Analysis
      • Debugging
        • Local Debugging
        • Remote Debugging
      • Format Document
      • Go to Definition
      • Packaging in Visual Studio
      • PowerShell 7 Support
      • PowerShell Interactive Window
      • Project System
        • Advanced
        • Debug
        • Build Events
      • Settings
        • General
        • .editorconfig
        • Analysis
        • Diagnostics
      • Tool Windows
      • Refactoring
      • Unit Test Adapter
      • User Interface Design
        • Windows Forms
  • PowerShell Pro Tools Documentation
    • Visual Studio Code
      • Automating Visual Studio Code
      • Code Conversion
      • Debugging
        • Run in New Terminal
        • One-Click Attach
      • Decompiler
      • Diagnostics
      • Enhanced Hover
      • Generating a UI from a function
      • Generate a Tool from a Function
      • Packaging in Visual Studio Code
      • Pin Session
      • PowerShell Explorer
      • Profiler
      • Sign On Save
      • RapidSense
      • Refactoring
      • Rename Symbols
      • Quick Scripts
      • Windows Forms Designer
    • Installers
    • Packaging
      • Package.psd1
      • PowerShell Packager
      • Package Hosts
      • Package as Service
      • Packaging on Linux
      • Packaging on Mac OS X
      • Continuous Integration
      • Anti-Virus
    • PowerShell Module
      • Global Hotkeys
      • Show-PSEditor
      • Show-PSScriptPad
      • Show-TUIDesigner
      • ConvertTo-CSharp
      • ConvertTo-PowerShell
      • Merge-Script
      • Install-PoshProToolsLicense
      • about_MergeScriptConfig
      • Show-WinFormDesigner
    • PowerShell Protect
      • Getting Started
      • Installation
      • Actions
      • Rules
      • Configuration
    • PSCommander
    • PSScriptPad
    • Installation and Licensing
      • Visual Studio Offline Installation
  • Changelog
    • PowerShell Tools for Visual Studio
    • PowerShell Pro Tools for Visual Studio Code
    • PowerShell Packager
    • PSScriptPad
    • PowerShell Pro Tools Module
Powered by GitBook
On this page
  • Requirements for Packaging
  • Compiling a Script
  • Configuration Packaging
  • Root Package.psd1
  • Scoped Package.psd1
  • Package.psd1 template
  1. PowerShell Pro Tools Documentation
  2. Visual Studio Code

Packaging in Visual Studio Code

Information about compiling PowerShell Scripts into executables with VS Code.

PreviousGenerate a Tool from a FunctionNextPin Session

Last updated 10 months ago

PowerShell Pro Tools provides an . PowerShell Pro Tools takes advantage of the package.psd1 file to configure packaging for scripts within VS Code.

Requirements for Packaging

  • PowerShell Pro Tools Visual Studio Code Extension

  • .NET Core SDK 2.0 or later

Compiling a Script

To compile a script into an executable, open a PS1 file. In the top right of the toolbar, you will find a Package Script as Exe button. Clicking this button will start the packaging process.

If this is the first time you have clicked the button, a package.psd1 file will be created in the current workspace's root. So for example, if you have the folder C:\src\scripts open in Visual Studio Code, the file C:\src\scripts\package.psd1 will be created.

Next, the packaging process will start. The PowerShell Pro Tools Output Pane will be activated and will display log information about the packaging process.

Configuration Packaging

The default configuration will look something like this.

@{
    Root = 'c:\Users\adamr\Desktop\test\test\test.ps1'
    OutputPath = 'c:\Users\adamr\Desktop\test\out'
    Package = @{
        Enabled = $true
        Obfuscate = $false
        HideConsoleWindow = $false
        DotNetVersion = 'v4.6.2'
        FileVersion = '1.0.0'
        FileDescription = ''
        ProductName = ''
        ProductVersion = ''
        Copyright = ''
        RequireElevation = $false
        ApplicationIconPath = ''
        PackageType = 'Console'
    }
    Bundle = @{
        Enabled = $true
        Modules = $true
        # IgnoredModules = @()
    }
}

Root Package.psd1

The root package.psd1 file is generated at the root of the current workspace folder. Here's an example of a file structure with a root package.psd1 file. Clicking Package Script as Exe on an script will use this package.psd1 file.

Scoped Package.psd1

You can also include the package.psd1 file in a particular folder. When packaging scripts in that folder, the scoped package.psd1 file will be used.

Take the following folder structure for example.

When packaging the test\test.ps1 file, the test\package.psd1 will be used to package the script. When packaging the test2\test2.ps1 file, the test\package.psd1 file will be used. The root package.psd1 will used when packaging test3\test3.ps1 because that folder does not have a scoped package config file.

Package.psd1 template

You can set the package.psd1 template that is used to create the default package.psd1 by setting the path to the file within your settings.

You can use two replacement variables that will be set when the file is created.

$root - Replaced by the path to the PS1 file being packaged

$outputPath - Path to the directory to output to.

To configure packaging, you can change settings within the generated package.psd1 file. You can learn more about the syntax of the file by .

clicking here
extension for Visual Studio Code
Package Script as Exe Button