### Install psake using Bootstrap Script Source: https://github.com/psake/docs/blob/main/README.md This command bootstraps the psake project, typically used for initial setup and dependency installation. It is the first step in getting psake ready for use. ```powershell .\builds.ps1 -Bootstrap ``` -------------------------------- ### Install psake via PowerShell Source: https://github.com/psake/docs/blob/main/docs/intro.md Installs the psake module using the built-in PowerShell package manager. It covers installation via PowerShellGet and the newer PSResourceGet. ```PowerShell # PowerShellGet Install-Module psake # PSResourceGet Install-PSResource psake ``` -------------------------------- ### Get Examples for Assert Function Source: https://github.com/psake/docs/blob/main/docs/tutorial-basics/getting-help.md Retrieve specific usage examples for a psake function, such as Assert, by using Get-Help with the -examples parameter. This provides practical scenarios for function usage. ```PowerShell C:\PS>Get-Help Assert -examples NAME Assert SYNOPSIS Helper function for "Design by Contract" assertion checking. -------------------------- EXAMPLE 1 -------------------------- C:\PS>Assert $false "This always throws an exception" This example always throws an exception -------------------------- EXAMPLE 2 -------------------------- C:\PS>Assert ( ($i % 2) -eq 0 ) "%i is not an even number" This example may throw an exception if $i is not an even number ``` -------------------------------- ### psake Build Script Example Source: https://github.com/psake/docs/blob/main/docs/intro.md Demonstrates a basic psake build script defining tasks and their dependencies. Tasks like 'Compile' depend on 'Init' and 'Clean', showcasing psake's dependency management. ```PowerShell Task Compile -Depends Init,Clean { "compile" } Task Clean -Depends Init { "clean" } Task Init { "init" } ``` -------------------------------- ### Install psake via Chocolatey Source: https://github.com/psake/docs/blob/main/docs/intro.md Installs psake using the Chocolatey package manager. This command is executed within a PowerShell or command prompt environment. ```Shell choco install psake ``` -------------------------------- ### Psake TaskSetup Example 1 Source: https://github.com/psake/docs/blob/main/docs/commands/TaskSetup.mdx Demonstrates a basic Psake build script using TaskSetup to log the current task name before execution. It shows the setup scriptblock receiving the task context implicitly. ```PowerShell Task default -depends Test Task Test -depends Compile, Clean { } Task Compile -depends Clean { } Task Clean { } TaskSetup { "Running 'TaskSetup' for task $context.Peek().currentTaskName" } ``` -------------------------------- ### Get Help for Invoke-psake Source: https://github.com/psake/docs/blob/main/docs/tutorial-basics/getting-help.md Import the psake.psm1 module and use Get-Help Invoke-psake -full to retrieve comprehensive help documentation for the Invoke-psake function. ```PowerShell # First import the psake.psm1 file Import-Module .\psake.psm1 Get-Help Invoke-psake -full ``` -------------------------------- ### Start Local Development Server with psake Source: https://github.com/psake/docs/blob/main/README.md Starts a local development server for the psake project. This command allows for live preview of changes without requiring a full server restart, facilitating rapid development. ```powershell .\build.ps1 -Task Server ``` -------------------------------- ### Get Detailed Help for Invoke-psake Source: https://github.com/psake/docs/blob/main/docs/tutorial-basics/run-psake.md This snippet illustrates how to obtain comprehensive help for the Invoke-psake function, which is available after importing the psake module. ```PowerShell Import-Module psake Get-Help Invoke-psake -full ``` -------------------------------- ### Psake Build Script Example Source: https://github.com/psake/docs/blob/main/docs/commands/Task.mdx Illustrates a sample Psake build script, demonstrating how to define tasks, specify dependencies between them, and include actions. It also shows the expected output and build time report. ```PowerShell A sample build script is shown below: ```powershell Task default -Depends Test Task Test -Depends Compile, Clean { "This is a test" } Task Compile -Depends Clean { "Compile" } Task Clean { "Clean" } ``` The 'default' task is required and should not contain an 'Action' parameter. It uses the 'Depends' parameter to specify that 'Test' is a dependency. The 'Test' task uses the 'Depends' parameter to specify that 'Compile' and 'Clean' are dependencies. The 'Compile' task depends on the 'Clean' task. Note: The 'Action' parameter is defaulted to the script block following the 'Clean' task. An equivalent 'Test' task is shown below: ```powershell Task Test -Depends Compile, Clean -Action { $testMessage } ``` The output for the above sample build script is shown below: ``` Executing task, Clean... Clean Executing task, Compile... Compile Executing task, Test... This is a test Build Succeeded! ---------------------------------------------------------------------- Build Time Report ---------------------------------------------------------------------- Name Duration ---- -------- Clean 00:00:00.0065614 Compile 00:00:00.0133268 Test 00:00:00.0225964 Total: 00:00:00.0782496 ``` ``` -------------------------------- ### Configure Hudson Job to Run Psake Script Source: https://github.com/psake/docs/blob/main/docs/ci-examples/hudson.md This example demonstrates how to configure a Hudson job to execute the psake helper script. It shows the command line that Hudson should run, which invokes PowerShell and passes the psake script along with its build file parameter. This setup ensures that psake builds are triggered correctly within the CI environment. ```powershell powershell.exe "& 'psake.ps1 psakefile.ps1'" ``` -------------------------------- ### Example psake Build Script Source: https://github.com/psake/docs/blob/main/docs/tutorial-advanced/structure-of-a-psake-build-script.md Demonstrates a basic psake build script structure using tasks and dependencies. It shows how to define a default task that depends on other tasks like Test, Compile, and Clean. ```PowerShell Task default -Depends Test Task Test -Depends Compile, Clean { "This is a test" } Task Compile -Depends Clean { "Compile" } Task Clean { "Clean" } ``` -------------------------------- ### List psake Module Functions Source: https://github.com/psake/docs/blob/main/docs/tutorial-basics/getting-help.md Use the Get-Command cmdlet with the -module parameter to list all available functions within the psake PowerShell module, showing their names and definitions. ```PowerShell C:\Software\psake> Get-Command -module psake CommandType Name Definition ----------- ---- ---------- Function Assert ... Function Exec ... Function FormatTaskName ... Function Include ... Function Invoke-psake ... Function Properties ... Function Task ... Function TaskSetup ... Function TaskTearDown ... ``` -------------------------------- ### Set PowerShell Breakpoint Syntax and Example Source: https://github.com/psake/docs/blob/main/docs/tutorial-advanced/debug-script.md Demonstrates the syntax for setting a breakpoint in a PowerShell script using `Set-PSBreakpoint`. It shows how to specify the script file and line number, and provides a practical example for debugging psake scripts. ```PowerShell Set-PSBreakpoint [-Script] [-Line] [[-Column] ] [-Action ] [] ex. Set-PSBreakPoint -script psakefile.ps1 -line 25 ``` -------------------------------- ### Install psake via Chocolatey Source: https://github.com/psake/docs/blob/main/docs/tutorial-basics/installing.md Installs the psake module using the Chocolatey package manager. Ensure Chocolatey is installed and configured on your system before running this command. ```powershell choco install psake ``` -------------------------------- ### Helper Script for psake Configuration Source: https://github.com/psake/docs/blob/main/docs/tutorial-basics/run-psake.md This example shows a helper script that configures psake to use a specific .NET framework version (e.g., 4.0) by passing the -framework parameter to Invoke-psake. ```PowerShell Import-Module (join-path $PSScriptRoot psake.psm1) -force Invoke-psake -framework '4.0' ``` -------------------------------- ### Psake Framework Command Example Source: https://github.com/psake/docs/blob/main/docs/commands/Framework.mdx Demonstrates how to use the Psake Framework command to set the .NET framework version to '4.0' for a build. It includes a sample task dependency structure showing how this setting might be applied within a Psake script. ```PowerShell Framework "4.0" Task default -depends Compile Task Compile -depends Clean { msbuild /version } # The script above will output detailed version of msbuid v4 ``` -------------------------------- ### psake Script with Properties Source: https://github.com/psake/docs/blob/main/docs/tutorial-basics/parameters-properties.md An example psake build script demonstrating property overrides. It initializes properties and asserts their values after potential overrides from Invoke-psake. ```powershell properties { $x = $null $y = $null $z = $null } task default -depends TestProperties task TestProperties { Assert ($x -ne $null) "x should not be null" Assert ($y -ne $null) "y should not be null" Assert ($z -eq $null) "z should be null" } ``` -------------------------------- ### Install psake via PowerShell Package Manager Source: https://github.com/psake/docs/blob/main/docs/tutorial-basics/installing.md Installs the psake module using PowerShell's built-in package management tools, PowerShellGet or PSResourceGet. This is a common method for users with PowerShell 5.1 or later. ```powershell Install-Module psake # Or using PSResourceGet Install-PSResource psake ``` -------------------------------- ### Assert Example: Always Fails (PowerShell) Source: https://github.com/psake/docs/blob/main/docs/commands/Assert.mdx Demonstrates using the Assert command to create an assertion that always fails, triggering an exception. ```PowerShell Assert $false "This always throws an exception" ``` -------------------------------- ### Psake Build Error Example Source: https://github.com/psake/docs/blob/main/docs/tutorial-advanced/logging-errors.md An example of the detailed error output generated by a psake build script when an error occurs. This output is intended to be captured by CI servers. ```powershell ---------------------------------------------------------------------- 4/25/2010 2:36:21 PM: An Error Occurred. See Error Details Below: ---------------------------------------------------------------------- ErrorRecord PSMessageDetails : Exception : System.Management.Automation.RuntimeException: This is a test TargetObject : This is a test CategoryInfo : OperationStopped: (This is a test:String) [], RuntimeException FullyQualifiedErrorId : This is a test ErrorDetails : InvocationInfo : System.Management.Automation.InvocationInfo PipelineIterationInfo : {} ErrorRecord.InvocationInfo MyCommand : BoundParameters : {} UnboundArguments : {} ScriptLineNumber : 4 OffsetInLine : 7 HistoryId : 34 ScriptName : C:\Users\Daddy\Documents\Projects\helloWorld\Build\LogError.ps1 Line : throw "This is a test" PositionMessage : At C:\Users\Daddy\Documents\Projects\helloWorld\Build\LogError.ps1:4 char:7 + throw <<<< "This is a test" InvocationName : throw PipelineLength : 0 PipelinePosition : 0 ExpectingInput : False CommandOrigin : Internal Exception 0000000000000000000000000000000000000000000000000000000000000000000000 ErrorRecord : This is a test StackTrace : WasThrownFromThrowStatement : True Message : This is a test Data : {} InnerException : TargetSite : HelpLink : Source : ---------------------------------------------------------------------- Script Variables ---------------------------------------------------------------------- Name Value ---- ----- _ args {} context {System.Collections.Hashtable} Error {} false False input System.Collections.ArrayList+ArrayListEnumeratorSimple MaximumAliasCount 4096 MaximumDriveCount 4096 MaximumErrorCount 256 MaximumFunctionCount 4096 MaximumVariableCount 4096 MyInvocation System.Management.Automation.InvocationInfo null psake {build_script_file, version, default_build_file_name, use_exit_on_error...} this ``` -------------------------------- ### Psake Include Command Syntax and Example (PowerShell) Source: https://github.com/psake/docs/blob/main/docs/commands/Include.mdx This section details the syntax for the Psake 'Include' command, which integrates external PowerShell script files into the current build script's scope. It explains how to use the command and provides a sample build script demonstrating its application for including utility functions. ```PowerShell Include [-fileNamePathToInclude] [-ProgressAction ] [] ``` ```PowerShell A sample build script is shown below: Include ".\build_utils.ps1" Task default -depends Test Task Test -depends Compile, Clean { } Task Compile -depends Clean { } Task Clean { } ``` -------------------------------- ### Psake TaskSetup Example 2 Source: https://github.com/psake/docs/blob/main/docs/commands/TaskSetup.mdx Illustrates using TaskSetup to access the task context explicitly via a parameter. The scriptblock receives the task object, allowing access to its properties like 'Name'. ```PowerShell Task default -depends Test Task Test -depends Compile, Clean { } Task Compile -depends Clean { } Task Clean { } TaskSetup { param($task) "Running 'TaskSetup' for task $($task.Name)" } ``` -------------------------------- ### Psake Properties Example Source: https://github.com/psake/docs/blob/main/docs/commands/Properties.mdx Illustrates the usage of the Properties function in a Psake build script to declare build-specific variables like build directories and connection strings. ```powershell Properties { $build_dir = "c:\build" $connection_string = "datasource=localhost;initial catalog=northwind;integrated security=sspi" } Task default -depends Test Task Test -depends Compile, Clean { } Task Compile -depends Clean { } Task Clean { } Note: Multiple "Properties" functions can be defined within a build script. ``` -------------------------------- ### psake Script Using Parameters Source: https://github.com/psake/docs/blob/main/docs/tutorial-basics/parameters.md An example psake build script (`parameters.ps1`) that defines properties based on passed parameters (`$p1`, `$p2`) and includes a task to assert the property's value. This script illustrates how parameters are accessed within a psake build. ```PowerShell properties { $my_property = $p1 + $p2 } task default -depends TestParams task TestParams { Assert ($my_property -ne $null) '$my_property should not be null' } ``` -------------------------------- ### Get-PSakeScriptTasks Cmdlet Documentation Source: https://github.com/psake/docs/blob/main/docs/commands/Get-PSakeScriptTasks.mdx Provides meta data about tasks defined in a Psake script. It takes an optional build file path and returns task details including dependencies and aliases. This documentation covers the cmdlet's syntax, parameters, and usage examples. ```APIDOC Get-PSakeScriptTasks Synopsis: Returns meta data about all the tasks defined in the provided psake script. Syntax: Get-PSakeScriptTasks [[-buildFile] ] [-ProgressAction ] [] Description: Returns meta data about all the tasks defined in the provided psake script. Parameters: -buildFile The path to the psake build script to read the tasks from. Type: String Parameter Sets: (All) Aliases: Required: False Position: 1 Default value: None Accept pipeline input: False Accept wildcard characters: False -ProgressAction {{ Fill ProgressAction Description }} Type: ActionPreference Parameter Sets: (All) Aliases: proga Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False CommonParameters: This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). Example: Get-PSakeScriptTasks -buildFile '.\build.ps1' Output: DependsOn Alias Name Description --------- ----- ---- ----------- {} Compile {} Clean {Test} Default {Clean, Compile} Test Gets the psake tasks contained in the 'build.ps1' file. Related Links: [Invoke-psake](Invoke-psake.mdx) ``` -------------------------------- ### Psake FormatTaskName Example: Script Block Source: https://github.com/psake/docs/blob/main/docs/commands/FormatTaskName.mdx Illustrates using a script block with the Psake FormatTaskName command for dynamic task name formatting. This example colors the task names blue during execution. ```PowerShell Task default -depends TaskA, TaskB, TaskC FormatTaskName { param($taskName) write-host "Executing Task: $taskName" -foregroundcolor blue } Task TaskA { "TaskA is executing" } Task TaskB { "TaskB is executing" } Task TaskC { "TaskC is executing" } ``` -------------------------------- ### Psake FormatTaskName Example: Format String Source: https://github.com/psake/docs/blob/main/docs/commands/FormatTaskName.mdx Demonstrates using a string format with the Psake FormatTaskName command to customize task name output. This example shows how to wrap task names in custom delimiters. ```PowerShell Task default -depends TaskA, TaskB, TaskC FormatTaskName "-------- {0} --------" Task TaskA { "TaskA is executing" } Task TaskB { "TaskB is executing" } Task TaskC { "TaskC is executing" } # Expected Output: # -------- TaskA -------- # TaskA is executing # -------- TaskB -------- # TaskB is executing # -------- TaskC -------- # TaskC is executing # # Build Succeeded! ``` -------------------------------- ### Psake Framework Command Description Source: https://github.com/psake/docs/blob/main/docs/commands/Framework.mdx Details the functionality of the Psake Framework command, which accepts a string specifying the .NET framework version. It lists all supported versions, including bitness variants, and explains the default behavior and how bitness is detected. ```PowerShell This function will accept a string containing version of the .NET framework to use during build. Possible values: '1.0', '1.1', '2.0', '2.0x86', '2.0x64', '3.0', '3.0x86', '3.0x64', '3.5', '3.5x86', '3.5x64', '4.0', '4.0x86', '4.0x64', '4.5', '4.5x86', '4.5x64', '4.5.1', '4.5.1x86', '4.5.1x64'. Default is '3.5*', where x86 or x64 will be detected based on the bitness of the PowerShell process. ``` -------------------------------- ### Build psake Project Source: https://github.com/psake/docs/blob/main/README.md Generates the static content for the psake project into the 'build' directory. The output can then be served by any static content hosting service. ```powershell .\build.ps1 -Task Build ``` -------------------------------- ### Run psake via Module Import Source: https://github.com/psake/docs/blob/main/docs/tutorial-basics/run-psake.md This snippet demonstrates the first method to run psake by importing the psake module and then calling the Invoke-psake function with a psakefile. ```PowerShell Import-Module psake Invoke-psake .\psakefile.ps1 ``` -------------------------------- ### Psake TaskSetup Command Parameters Source: https://github.com/psake/docs/blob/main/docs/commands/TaskSetup.mdx Provides detailed information about the parameters accepted by the Psake TaskSetup command, including their types, requirements, and aliases. ```APIDOC TaskSetup: -setup - Description: A scriptblock to execute before each task. - Type: ScriptBlock - Required: True - Position: 1 - Aliases: None -ProgressAction - Description: {{ Fill ProgressAction Description }} - Type: ActionPreference - Required: False - Position: Named - Aliases: proga - Description: Supports common parameters like -Debug, -ErrorAction, -Verbose, etc. - See: http://go.microsoft.com/fwlink/?LinkID=113216 for more information. ``` -------------------------------- ### Assert Example: Even Number Check (PowerShell) Source: https://github.com/psake/docs/blob/main/docs/commands/Assert.mdx Shows how to use the Assert command to check if a variable is an even number, with notes on condition evaluation. ```PowerShell Assert ( ($i % 2) -eq 0 ) "$i is not an even number" # Note: It might be necessary to wrap the condition with paranthesis to force PS to evaluate the condition # so that a boolean value is calculated and passed into the 'conditionToCheck' parameter. # Example: # Assert 1 -eq 2 "1 doesn't equal 2" <- This will fail # PS will pass 1 into the condtionToCheck variable and PS will look for a parameter called "eq" and # throw an exception with the following message "A parameter cannot be found that matches parameter name 'eq'" # The solution is to wrap the condition in () so that PS will evaluate it first. # Assert (1 -eq 2) "1 doesn't equal 2" ``` -------------------------------- ### Psake Framework Command Parameters Source: https://github.com/psake/docs/blob/main/docs/commands/Framework.mdx Provides detailed information on the parameters accepted by the Psake Framework command. It specifies the type, requirements, and aliases for each parameter, including the core '-framework' parameter and the standard '-ProgressAction'. ```PowerShell -framework Version of the .NET framework to use during build. Type: String Parameter Sets: (All) Aliases: Required: True Position: 1 Default value: None Accept pipeline input: False Accept wildcard characters: False -ProgressAction {{ Fill ProgressAction Description }} Type: ActionPreference Parameter Sets: (All) Aliases: proga Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ``` -------------------------------- ### psake Script with Parameters Source: https://github.com/psake/docs/blob/main/docs/tutorial-basics/parameters-properties.md An example psake build script that utilizes parameters passed via Invoke-psake. It defines a property based on input parameters and asserts its value. ```powershell properties { $my_property = $p1 + $p2 } task default -depends TestParams task TestParams { Assert ($my_property -ne $null) '$my_property should not be null' } ``` -------------------------------- ### psake Build Script Functions Source: https://github.com/psake/docs/blob/main/docs/tutorial-advanced/structure-of-a-psake-build-script.md Lists and describes the core functions available within psake build scripts, such as _Include, _Properties, _Task, _Exec, and _Assert. It details their purpose and whether they are required. ```APIDOC _Include(): Call this function to have psake include the functions of another file into your script - Required: no _Properties(): Call this function to set your properties - Required: no _Task(): This is the main function that you write to execute a step in your build script. NOTE: There can be only one task function that is named "default" in your psake script and it cannot contain any code. psake will throw an exception if it finds more than one default task function or if the default task function contains code - Required: yes _Exec(): Call a command-line program and throw an exception if it returns a non-zero DOS exit code - Required: no _Assert(): Use to simplify writing conditional statements - Required: no _FormatTaskName(): Allows you to reformat how psake displays the currently running task - Required: no _TaskSetup(): A function that will run before each task is executed - Required: no _TaskTearDown(): A function that will run after each task - Required: no _BuildSetup(): A script block that will run before the first task starts - Required: no _BuildTearDown(): A script block that will run when either all tasks have completed, or the build has failed - Required: no ``` -------------------------------- ### Basic psake Build Task Source: https://github.com/psake/docs/blob/main/docs/build-types/dot-net-solution.md A simple psake script demonstrating a default task that depends on a Build task. The Build task executes an MSBuild command to build a Visual Studio solution file. ```powershell Task Default -depends Build Task Build { Exec { msbuild "helloWorld.sln" } } ``` -------------------------------- ### Generate Task Documentation Source: https://github.com/psake/docs/blob/main/docs/commands/Invoke-psake.mdx Prints a report of all tasks, their dependencies, and descriptions from the specified build script, '.build.ps1', and then exits. ```PowerShell Invoke-psake .\build.ps1 -docs ``` -------------------------------- ### Update and Reference Script-Scoped Variable in psake Source: https://github.com/psake/docs/blob/main/docs/tutorial-advanced/variable-referencing.md This example illustrates updating a variable declared in 'properties' using the `$script:` scope modifier within a task. It then shows how another task can access this modified script-scoped variable. ```powershell properties { $x = 1 } task default -depends TaskA, TaskB task TaskA { $script:x = 100 '$x = ' + $script:x } task TaskB { '$x = ' + $script:x } ``` -------------------------------- ### Invoke-psake Command Parameters Source: https://github.com/psake/docs/blob/main/docs/commands/Invoke-psake.mdx Documentation for the Invoke-psake PowerShell command, detailing its parameters, types, and usage. This covers script file selection, task execution, framework targeting, and parameter/property passing. ```APIDOC Invoke-psake Runs a psake build script. SYNTAX: Invoke-psake [[-buildFile] ] [[-taskList] ] [[-framework] ] [-docs] [[-parameters] ] [[-properties] ] [[-initialization] ] [-nologo] [-detailedDocs] [-Notr] [-ProgressAction ] [] PARAMETERS: -buildFile: The path to the psake build script to execute. Type: String Required: False Position: 1 -taskList: A comma-separated list of task names to execute. Type: String[] Required: False Position: 2 Default value: @() -framework: The version of the .NET framework to use during build. Can append x86 or x64 to force bitness. Possible values: '1.0', '1.1', '2.0', '2.0x86', '2.0x64', '3.0', '3.0x86', '3.0x64', '3.5', '3.5x86', '3.5x64', '4.0', '4.0x86', '4.0x64', '4.5', '4.5x86', '4.5x64', '4.5.1', '4.5.1x86', '4.5.1x64' Type: String Required: False Position: 3 -docs: Prints a list of tasks and their descriptions. Type: SwitchParameter Required: False Position: 4 -parameters: Passes parameters to the build script. Type: Hashtable Required: False Position: 5 -properties: Overrides existing properties in the build script. Type: Hashtable Required: False Position: 6 -initialization: A script block to run before tasks are executed. Type: ScriptBlock Required: False Position: 7 -nologo: Suppresses the display of the psake logo. Type: SwitchParameter Required: False -detailedDocs: Prints detailed documentation for tasks. Type: SwitchParameter Required: False -Notr: Disables task execution tracing. Type: SwitchParameter Required: False : Includes standard PowerShell common parameters like -Verbose, -Debug, -ErrorAction, etc. Type: Required: False ``` -------------------------------- ### Create and Reference Script-Scoped Variable Between Tasks Source: https://github.com/psake/docs/blob/main/docs/tutorial-advanced/variable-referencing.md This example demonstrates creating a new variable with script scope ('$script:y') within one task and then referencing it from another task. This allows sharing state between tasks that are not directly dependent. ```powershell task default -depends TaskA, TaskB task TaskA { $script:y = 100 '$y = ' + $script:y } task TaskB { '$y = ' + $script:y } ``` -------------------------------- ### Assert Command API Reference (PowerShell) Source: https://github.com/psake/docs/blob/main/docs/commands/Assert.mdx Detailed API documentation for the Psake Assert command, including parameter descriptions, types, and usage notes. ```APIDOC Assert: Description: This is a helper function that makes the code less noisy by eliminating many of the "if" statements that are normally required to verify assumptions in the code. Parameters: -conditionToCheck: Type: Object Required: True Description: The boolean condition to evaluate. Accept pipeline input: False -failureMessage: Type: String Required: True Description: The error message used for the exception if the conditionToCheck parameter is false. Accept pipeline input: False -ProgressAction: Type: ActionPreference Required: False Aliases: proga Description: {{ Fill ProgressAction Description }} Accept pipeline input: False CommonParameters: Supports: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). Related Links: [Exec](Exec.mdx) [FormatTaskName](FormatTaskName.mdx) [Framework](Framework.mdx) [Get-PSakeScriptTasks](Get-PSakeScriptTasks.mdx) [Include](Include.mdx) [Invoke-psake](Invoke-psake.mdx) [Properties](Properties.mdx) [Task](Task.mdx) [TaskSetup](TaskSetup.mdx) [TaskTearDown](TaskTearDown.mdx) ``` -------------------------------- ### Invoke-psake with Parameters Source: https://github.com/psake/docs/blob/main/docs/tutorial-basics/parameters.md Demonstrates how to invoke a psake build script (`parameters.ps1`) and pass parameters using the `-parameters` argument of the `Invoke-psake` function. Parameters are supplied as a PowerShell hashtable. ```PowerShell Invoke-psake .\parameters.ps1 -parameters @{"p1"="v1";"p2"="v2"} ``` -------------------------------- ### Psake Framework Command Syntax Source: https://github.com/psake/docs/blob/main/docs/commands/Framework.mdx Defines the syntax for the Psake Framework command, specifying the required framework version parameter and common PowerShell parameters. It outlines the structure for setting the .NET framework version for a build process. ```PowerShell Framework [-framework] [-ProgressAction ] [] ``` -------------------------------- ### Reference Properties Variable in psake Tasks Source: https://github.com/psake/docs/blob/main/docs/tutorial-advanced/variable-referencing.md This example shows how to declare a variable in the 'properties' block and reference it from different task functions in a psake build script. Variables declared in 'properties' have script-level scope and are accessible globally within the build. ```powershell properties { $x = 1 } task default -depends TaskA, TaskB task TaskA { '$x = ' + $x } task TaskB { '$x = ' + $x } ``` -------------------------------- ### psake Task ContinueOnError Example Source: https://github.com/psake/docs/blob/main/docs/tutorial-advanced/build-script-resilience.md Demonstrates how to use the 'ContinueOnError' switch in a psake build script. This allows a task to fail and throw an exception, but the build process will continue with subsequent tasks, preventing a complete build failure. Dependent tasks of the failing task will still execute. ```powershell Task default -Depends TaskA Task TaskA -Depends TaskB { "Task - A" } Task TaskB -Depends TaskC -ContinueOnError { "Task - B" throw "I failed on purpose!" } Task TaskC { "Task - C" } ``` -------------------------------- ### Invoke-psake with Parameters Source: https://github.com/psake/docs/blob/main/docs/tutorial-basics/parameters-properties.md Demonstrates how to pass parameters to a psake build script using the -parameters argument. Parameters are provided as a PowerShell hashtable. ```powershell Invoke-psake .\parameters.ps1 -parameters @{"p1"="v1";"p2"="v2"} ``` -------------------------------- ### psake Build Script BNF Source: https://github.com/psake/docs/blob/main/docs/tutorial-advanced/structure-of-a-psake-build-script.md Provides the Backus-Naur Form (BNF) grammar for defining the structure of a psake build script, illustrating the valid syntax for script components. ```APIDOC ::= | | | | | ``` -------------------------------- ### Pass TeamCity Parameters to psake Scripts Source: https://github.com/psake/docs/blob/main/docs/ci-examples/team-city.md This example shows how to pass TeamCity build parameters into your psake scripts. Parameters are passed as a hash table to the psake executable, allowing dynamic configuration of your builds based on TeamCity variables like build number or personal build status. ```PowerShell & .\psake.ps1 -parameters @{build_number=%build.number%} ``` ```PowerShell & .\psake.ps1 -parameters @{build_number=%build.number%; personal_build=%build.is.personal%} ``` -------------------------------- ### Psake Include Command Parameters (APIDOC) Source: https://github.com/psake/docs/blob/main/docs/commands/Include.mdx Detailed documentation for the parameters of the Psake 'Include' command, including their types, requirements, and aliases, as well as common parameters supported by PowerShell cmdlets. ```APIDOC Include Command Parameters: -fileNamePathToInclude: - Description: A string containing the path and name of the powershell file to include. - Type: String - Parameter Sets: (All) - Aliases: None - Required: True - Position: 1 - Default value: None - Accept pipeline input: False - Accept wildcard characters: False -ProgressAction: - Description: {{ Fill ProgressAction Description }} - Type: ActionPreference - Parameter Sets: (All) - Aliases: proga - Required: False - Position: Named - Default value: None - Accept pipeline input: False - Accept wildcard characters: False CommonParameters: - Description: This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - Type: N/A - Parameter Sets: (All) - Aliases: None - Required: False - Position: Named - Default value: None - Accept pipeline input: False - Accept wildcard characters: False ```