PageSourceSearch

https://psake.netlify.app/assets/js/3884f721.5352c933.js

js psake.netlify.app collected 2026-10-03 11:19:19 UTC 8,443 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkpsake=self.webpackChunkpsake||[]).push([[5048],{21986:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>o,contentTitle:()=>l,default:()=>p,frontMatter:()=>t,metadata:()=>s,toc:()=>c});const s=JSON.parse('{"id":"commands/Properties","title":"Properties","description":"Help page for the PowerShell Psake \\"Properties\\" command","source":"@site/docs/commands/Properties.mdx","sourceDirName":"commands","slug":"/commands/Properties","permalink":"/docs/commands/Properties","draft":false,"unlisted":false,"editUrl":null,"tags":[],"version":"current","frontMatter":{"id":"Properties","title":"Properties","description":"Help page for the PowerShell Psake \\"Properties\\" command","keywords":["PowerShell","Psake","Help","Documentation"],"hide_title":false,"hide_table_of_contents":false,"custom_edit_url":null},"sidebar":"referenceSidebar","previous":{"title":"Invoke-Task","permalink":"/docs/commands/Invoke-Task"},"next":{"title":"Task","permalink":"/docs/commands/Task"}}');var a=i(74848),r=i(28453);const t={id:"Properties",title:"Properties",description:'Help page for the PowerShell Psake "Properties" command',keywords:["PowerShell","Psake","Help","Documentation"],hide_title:!1,hide_table_of_contents:!1,custom_edit_url:null},l=void 0,o={},c=[{value:"SYNOPSIS",id:"synopsis",level:2},{value:"SYNTAX",id:"syntax",level:2},{value:"ScriptBlock (Default)",id:"scriptblock-default",level:3},{value:"Hashtable",id:"hashtable",level:3},{value:"DESCRIPTION",id:"description",level:2},{value:"EXAMPLES",id:"examples",level:2},{value:"EXAMPLE 1",id:"example-1",level:3},{value:"EXAMPLE 2",id:"example-2",level:3},{value:"EXAMPLE 3",id:"example-3",level:3},{value:"PARAMETERS",id:"parameters",level:2},{value:"-Hashtable",id:"-hashtable",level:3},{value:"-Properties",id:"-properties",level:3},{value:"CommonParameters",id:"commonparameters",level:3},{value:"INPUTS",id:"inputs",level:2},{value:"OUTPUTS",id:"outputs",level:2},{value:"NOTES",id:"notes",level:2},{value:"RELATED LINKS",id:"related-links",level:2},{value:"VERSION",id:"version",level:2}];function d(e){const n={a:"a",admonition:"admonition",code:"code",em:"em",h2:"h2",h3:"h3",p:"p",pre:"pre",...(0,r.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.admonition,{title:"This page was generated",type:"info",children:(0,a.jsxs)(n.p,{children:["Contributions are welcome in ",(0,a.jsx)(n.a,{href:"https://github.com/psake/psake",children:"Psake-repo"}),"."]})}),"\n",(0,a.jsx)(n.h2,{id:"synopsis",children:"SYNOPSIS"}),"\n",(0,a.jsx)(n.p,{children:"Define a scriptblock that contains assignments to variables that will be\navailable within all tasks in the build script"}),"\n",(0,a.jsx)(n.h2,{id:"syntax",children:"SYNTAX"}),"\n",(0,a.jsx)(n.h3,{id:"scriptblock-default",children:"ScriptBlock (Default)"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{children:"Properties [-Properties] <scriptblock> [<CommonParameters>]\n"})}),"\n",(0,a.jsx)(n.h3,{id:"hashtable",children:"Hashtable"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{children:"Properties [-Hashtable] <hashtable> [<CommonParameters>]\n"})}),"\n",(0,a.jsx)(n.h2,{id:"description",children:"DESCRIPTION"}),"\n",(0,a.jsx)(n.p,{children:'A build script may declare a "Properties" function which allows you to\ndefine variables that will be available within all the "Task" functions in\nthe build script.'}),"\n",(0,a.jsx)(n.h2,{id:"examples",children:"EXAMPLES"}),"\n",(0,a.jsx)(n.h3,{id:"example-1",children:"EXAMPLE 1"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-powershell",children:'Properties {\n    $build_dir = "c:\\build"\n    $connection_string = "datasource=localhost;initial catalog=northwind;integrated security=sspi"\n}\nTask default -depends Test\nTask Test -depends Compile, Clean {\n}\nTask Compile -depends Clean {\n}\nTask Clean {\n}\n'})}),"\n",(0,a.jsx)(n.p,{children:'Note: You can have more than one "Properties" function defined in the build script.'}),"\n",(0,a.jsx)(n.h3,{id:"example-2",children:"EXAMPLE 2"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-powershell",children:'Properties {\n    $script:build_dir = "c:\\build"\n    $script:connection_string = "datasource=localhost;initial catalog=northwind;integrated security=sspi"\n}\nTask Compile {\n    "Building to: $build_dir"  # No PSScriptAnalyzer warning, variable is recognized\n}\n'})}),"\n",(0,a.jsx)(n.p,{children:"Recommended: Use script-scoped variables to avoid PSScriptAnalyzer warnings\nThe $script: prefix has identical runtime behavior but satisfies\nPSScriptAnalyzer's static analysis requirements."}),"\n",(0,a.jsx)(n.h3,{id:"example-3",children:"EXAMPLE 3"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-powershell",children:'Properties {\n    $build_dir = "c:\\build"  # Warning: PSUseDeclaredVarsMoreThanAssignments\n}\nTask Compile {\n    "Building to: $build_dir"  # Works at runtime, but PSScriptAnalyzer warns\n}\n'})}),"\n",(0,a.jsx)(n.p,{children:"Alternative: Non-scoped variables (generates PSScriptAnalyzer warnings)"}),"\n",(0,a.jsx)(n.p,{children:"Variables still work correctly at runtime, but PSScriptAnalyzer cannot detect\nthat they will be used in tasks."}),"\n",(0,a.jsx)(n.h2,{id:"parameters",children:"PARAMETERS"}),"\n",(0,a.jsx)(n.h3,{id:"-hashtable",children:"-Hashtable"}),"\n",(0,a.jsx)(n.p,{children:"An alternative to the scriptblock parameter, you can provide a hashtable of\
1nkey-value pairs that will be converted into variables.\nThis is useful when\nyou want to define properties programmatically or from an external source."}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-yaml",children:"Type: System.Collections.Hashtable\nDefaultValue: ''\nSupportsWildcards: false\nAliases: []\nParameterSets:\n- Name: Hashtable\n  Position: 0\n  IsRequired: true\n  ValueFromPipeline: false\n  ValueFromPipelineByPropertyName: false\n  ValueFromRemainingArguments: false\nDontShow: false\nAcceptedValues: []\nHelpMessage: ''\n"})}),"\n",(0,a.jsx)(n.h3,{id:"-properties",children:"-Properties"}),"\n",(0,a.jsx)(n.p,{children:"The script block containing all the variable assignment statements"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-yaml",children:"Type: System.Management.Automation.ScriptBlock\nDefaultValue: ''\nSupportsWildcards: false\nAliases: []\nParameterSets:\n- Name: ScriptBlock\n  Position: 0\n  IsRequired: true\n  ValueFromPipeline: false\n  ValueFromPipelineByPropertyName: false\n  ValueFromRemainingArguments: false\nDontShow: false\nAcceptedValues: []\nHelpMessage: ''\n"})}),"\n",(0,a.jsx)(n.h3,{id:"commonparameters",children:"CommonParameters"}),"\n",(0,a.jsxs)(n.p,{children:["This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,\n-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,\n-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see\n",(0,a.jsx)(n.a,{href:"https://go.microsoft.com/fwlink/?LinkID=113216",children:"about_CommonParameters"}),"."]}),"\n",(0,a.jsx)(n.h2,{id:"inputs",children:"INPUTS"}),"\n",(0,a.jsx)(n.h2,{id:"outputs",children:"OUTPUTS"}),"\n",(0,a.jsx)(n.h2,{id:"notes",children:"NOTES"}),"\n",(0,a.jsx)(n.p,{children:"Properties scriptblocks are dot-sourced into each task's scope at\nruntime.\nVariables are not accessible outside of task scriptblocks."}),"\n",(0,a.jsx)(n.p,{children:"PSScriptAnalyzer may flag declared variables as unused \u2014 this is a\nfalse positive.\nUse the $script: prefix to suppress it (see examples)."}),"\n",(0,a.jsx)(n.h2,{id:"related-links",children:"RELATED LINKS"}),"\n",(0,a.jsx)(n.h2,{id:"version",children:"VERSION"}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsxs)(n.em,{children:["This page was generated using comment-based help in ",(0,a.jsx)(n.a,{href:"https://github.com/psake/psake",children:"Psake 5.0.4"}),"."]})})]})}function p(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(d,{...e})}):d(e)}},28453:(e,n,i)=>{i.d(n,{R:()=>t,x:()=>l});var s=i(96540);const a={},r=s.createContext(a);function t(e){const n=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:t(e.components),s.createElement(r.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.