Edit Default Package.psd1

Hello Guys,

I’m writing this post "I don’t know if it already asked before :slight_smile: " because I need to know how to modify the default Package.psd1 “Default Manifest (i don’t know the correct name of it)”, I’m nearby in the scripting world and is annoying to change every time the package.psd1 with adding the same parameters.

Thanks for your support, I appreciated it :slight_smile:

Edit :
PS: I’m using Visual Studio Code

Currently not possible but would be pretty easy to add.

What if we added a way to create a template package.psd1? For example, you could create it in %AppData%\PowerShellProTools. Then we would have some replacement parameters.

Something like:

@{
        Root = '$fileName'
        OutputPath = '$outputPath'
        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 = @()
        }
    }
    

First of all, thanks Adam for the quick Answer, I really appreciate it a lot.

looks good to have a template of it, because I have a real problem with the Execution policy so sometimes I forgot to add like today and I don’t know why if the execution policy is not declared, you cannot write to Regedit :frowning: .
So PowerShellArguments = '-ExecutionPolicy bypass ’ is important and RequireElevation = $true too "all of my script Require Elevation "

You can make my life simple :slight_smile:

I’ve added an option to the extension settings that will let you set a path to a package.psd1 template file.

https://docs.poshtools.com/powershell-pro-tools-documentation/visual-studio-code/packaging-in-visual-studio-code#package-psd1-template

It’s currently in the release pipeline and should be available soon.

I follow what you write and i have just one problem,
the value of package.psd1 "Root = ‘$fileName’ " will still like this and during compile dosent work.

Outputfile is ok and create the folder normally.

i wrong something?

    Exception running command: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.Exception: File $fileName does not exist.
   at PowerShellToolsPro.Packager.BundleStage.Execute(PackageProcess process, StageResult previousStage) in D:\a\1\s\PowerShellToolsPro.Packager\PackageProcess.cs:line 305
   at PowerShellToolsPro.Packager.PackageProcess.Execute() in D:\a\1\s\PowerShellToolsPro.Packager\PackageProcess.cs:line 63
   at PowerShellToolsPro.PoshToolsServer.Package(String packageFile) in D:\a\1\s\PowerShellProTools.Host\PoshToolsServer.cs:line 284
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at PowerShellToolsPro.PoshToolsServer.Start(String pipeName) in D:\a\1\s\PowerShellProTools.Host\PoshToolsServer.cs:line 95

It’s actually $root and not $fileName. Sorry about that.

@{
        Root = '$root'
        OutputPath = '$outputPath'
        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 = @()
        }
    }

Thanks a lot for quick answer :slight_smile: