Replies: 6 comments
-
@jperterm Thank you. It's an interesting use case and the issue. Let me play/think a little bit. |
Beta Was this translation helpful? Give feedback.
-
One possible approach Project structure:
Sample content of param (
[string]$TestCase
)
# code before
#...
. $TestCase\$TestCase.tasks.ps1
# code after
#... And here the content of task t1 {...}
... Having done this, calling |
Beta Was this translation helpful? Give feedback.
-
FWIW, I have created the demo: SubCases |
Beta Was this translation helpful? Give feedback.
-
Thank you for your immediate feedback! I'll try that out and give feedback here soon. |
Beta Was this translation helpful? Give feedback.
-
I checked your proposal, but it does not really fit for my use-case. I guess I somehow set you on the wrong track with my parameter example ( I understand that In your documentation you mention this:
The last sentence "A build script is designed to work for several or variable directories." matches my use-case best. Plus I want to be able to have the
Finally, as mentioned I landed in your docs about the Invoke-Build @args -File '..\common\common.1.build.ps1' -BuildRoot $PSScriptRoot So what I loose in the end is, that I cannot type Nonetheless, thank you for your help! UPDATE: The example for the |
Beta Was this translation helpful? Give feedback.
-
Yes, I see that your use case is more involved than my If you do not mind using dynamic parameters in subproject scripts (with a common helper, to avoid same boilerplate), this might be the way to explore. UPDATE: I've tried dynamic parameters. So far even with a helper it looks not so good, too much cryptic code noise. |
Beta Was this translation helpful? Give feedback.
-
Hi,
first of all: Invoke-Build is a really simple to use and straight-forward tool for a lot of build tasks, thanks a lot!
Now, I have a (maybe) special use-case in which I want to re-use a common build script in a repository with a lot of subprojects. Those subprojects are of similar type, but with different configurations. I manage these configurations with JSON files.
To illustrate by example:
Project structure:
Sample content of
common.build.ps1
:And here the content of
subproject1.build.ps1
:As you can see, I am dot-sourcing the
common.build.ps1
into the subproject build file. This allows me to make improvements to the common build script, without making copies again and again, and also managing different versions.To come to the point/problem:
Dot-sourcing the common script into the subproject works well with tasks. I can do
Invoke-Build Debug
andInvoke-Build ?
and I get no different behaviour as when having a full copy of the build script in each subproject.But when I want to pass parameters like
Invoke-Build Debug -TestCase test1
, then I getThis behaviour somehow makes sense when I compare with "normal" powershell scripts (not called via
Invoke-Build
). Every script has its own parameters and indeed the subproject build files have no parameters at all.Do you (or anyone) know what could be a best-practise for my use-case? I still want to be able to call
Invoke-Build
in the subproject.Beta Was this translation helpful? Give feedback.
All reactions