Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build can't be easily automated when a parser function is needed #201

Open
3 tasks done
DennisL68 opened this issue Jun 15, 2023 · 1 comment
Open
3 tasks done

Build can't be easily automated when a parser function is needed #201

DennisL68 opened this issue Jun 15, 2023 · 1 comment

Comments

@DennisL68
Copy link

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.

Steps to reproduce

Create a build script for a Crescendo configuration that requires an external script for parsing

. "$PSScriptRoot\helpers\parse.ps1"

Export-CrescendoModule -ConfigurationFile "$PSScriptRoot\crescendo\mycommand.json" -ModuleName MyCommand -Force

Expected behavior

The functions in parse.ps1 should be available for Export-CrescendoModule

(I'm actually not sure they will be available for any external scripts unless deployed from a console that has had the functions dot sourced.)

Actual behavior

Crescendo fails with error

Work around is to dot source the script by hand into the console that starts the build script

Error details

Exception: Cannot find output handler function 'XXX'.

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.10
PSEdition                      Core
GitCommitId                    7.2.10
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

1.1.0

Visuals

No response

@DennisL68 DennisL68 changed the title Build can't be easily automated if a parser function is needed Build can't be easily automated when a parser function is needed Aug 25, 2023
@victormaso
Copy link

My workaround is to execute a separate "Build.ps1" script that dot sources the helper functions ps1 and then executes the ps1 that contains your Export-CrecendoModule command. In my example all 3 ps1 files are in the same directory.

This approach creates a fresh PowerShell session and ensures and eliminates any clobber issues with changing functions in the same session before re-running .

I keep a separate PowerShell session open and I re-run the ". build.ps1" anytime I make modifications to crescendo jsons or the helper functions. This resolved my issues with Crescendo not finding the helper functions or not using the latest version and allowed me to keep helper functions in separate files.

. Build.ps1

. "$PSScriptRoot\Build_Functions.ps1"    #Contains All helper functions 
. "$PSScriptRoot\Build_Deploy.ps1"       #Contains Export-CrecendoModule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants