You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clarify parameters vs properties with decision guide and flow diagram
Enhanced the parameters-properties.md documentation to address common
confusion about when to use each approach:
- Added "Quick Decision Guide" section upfront for immediate clarity
- Included mermaid sequence diagram showing execution flow and variable
lifespan throughout the build process
- Restructured content with clear "When to Use" sections for both
parameters (input values) and properties (final overrides)
- Added side-by-side comparison examples demonstrating the timing difference
- Included comparison table highlighting key differences
- Added "Best Practices" section with real-world guidance
- Added warning about properties not recomputing derived values
- Concluded with summary and "Rule of Thumb" decision tip
The document now provides a clear decision framework for users to determine
which approach to use based on whether values are used for computation or
are final overrides.
@@ -4,87 +4,286 @@ description: "How to use parameters and properties in your build script."
4
4
sidebar_position: 11
5
5
---
6
6
7
-
To summarize the differences between passing parameters and properties to the
8
-
`Invoke-psake` function:
7
+
Parameters and properties are two different ways to pass values into your psake build scripts. Understanding when to use each one is crucial for creating flexible, maintainable build automation.
9
8
10
-
* Parameters and "properties" can both be passed to the Invoke-psake function
11
-
simultaneously
12
-
* Parameters are set before any "properties" blocks are run
13
-
* Properties are set after all "properties" blocks have run
9
+
## Quick Decision Guide
14
10
15
-
## Parameters
11
+
**Use Parameters when:**
12
+
- You need to pass external values that your properties blocks will use to compute derived values
13
+
- You want to provide inputs that determine how properties are calculated
14
+
- You're passing configuration from CI/CD systems or command-line arguments
16
15
17
-
You can pass parameters to your build script using the "parameters" parameter of
18
-
the Invoke-psake function. The following is an example:
16
+
**Use Properties when:**
17
+
- You need to override final property values after all computations are complete
18
+
- You want to replace default values defined in your build script
19
+
- You're overriding environment-specific settings (like connection strings or paths)
The example above runs the build script called `parameters.ps1` and passes in
25
-
parameters `p1` and `p2` with values `v1` and `v2`. The parameter value for the
26
-
"parameters" parameter (say that 10 times really fast!) is a PowerShell
27
-
hashtable where the name and value of each parameter is specified.
43
+
**Key Insight:** Parameters are set **before** properties blocks run, while property overrides are applied **after** all properties blocks have executed.
28
44
29
-
:::note
45
+
## When to Use Each
30
46
31
-
You don't need to use the "$" character when specifying the parameter names in
32
-
the hashtable.
47
+
### Use Parameters For: Input Values
33
48
34
-
:::
49
+
Parameters provide **input values** that your build script can use during the properties block execution phase. They're ideal for:
50
+
51
+
- Build configuration values (Debug/Release)
52
+
- Version numbers to be incorporated into file paths
53
+
- Feature flags that affect property calculations
54
+
- CI/CD system variables
55
+
56
+
**Example:** Using parameters to compute derived properties
You don't need to use the "$" character when specifying the property names in
68
-
the hashtable.
124
+
When you override a property, any derived values that were computed from it in the properties block are **NOT** automatically recalculated. In the example above, `$connectionString` would still contain the original computed value unless you override it directly as well.
69
125
70
126
:::
71
127
72
-
```powershell title="properties.ps1"
128
+
## Comparison: Side by Side
129
+
130
+
Let's see the difference with a concrete example:
131
+
132
+
```powershell title="build.ps1"
133
+
properties {
134
+
$env = $environment # Will be set if passed as parameter
135
+
$deployPath = "C:\Deploy\$env" # Computed from $env
0 commit comments