{"id":330,"date":"2010-04-12T12:00:00","date_gmt":"2010-04-12T18:00:00","guid":{"rendered":"http:\/\/jameskovacs.com\/2010\/04\/12\/psake-v4-00\/"},"modified":"2010-04-12T12:00:00","modified_gmt":"2010-04-12T18:00:00","slug":"psake-v4-00","status":"publish","type":"post","link":"https:\/\/www.jameskovacs.com\/index.php\/2010\/04\/12\/psake-v4-00\/","title":{"rendered":"psake v4.00"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px\" title=\"psake\" border=\"0\" alt=\"psake\" align=\"right\" src=\"https:\/\/www.jameskovacs.com\/wp-content\/uploads\/2010\/04\/image4.png\" width=\"200\" height=\"86\" \/> It is with great pleasure that I announce psake v4.00, which you can download <a href=\"http:\/\/github.com\/JamesKovacs\/psake\/zipball\/v4.00\" target=\"_blank\" rel=\"noopener\">here<\/a>. The project has grown up a great deal in the last few months. More projects are using psake for orchestrating their builds and we have more developers submitting patches. I\u2019m really pleased with how psake is growing up. GitHub has become our coordination point for the project, which you can find <a href=\"http:\/\/github.com\/JamesKovacs\/psake\" target=\"_blank\" rel=\"noopener\">here<\/a>, and we will be retiring the Google Code site. Jorge has started work on a FAQ, which will make it easier for developers to get started with psake. Look for it on the GitHub wiki in the next few weeks.<\/p>\n<h2>What\u2019s new in psake v4.00?<\/h2>\n<ul>\n<li>Exec helper function <\/li>\n<li>.NET 4.0 support<\/li>\n<li>64-bit support<\/li>\n<li>psake.ps1 helper script<\/li>\n<li>Support for parameters &amp; properties <\/li>\n<li>Support for nested builds<\/li>\n<li>Tab expansion<\/li>\n<li>Invoke default script<\/li>\n<li>Various minor bug fixes <\/li>\n<\/ul>\n<h3>Exec Helper Function<\/h3>\n<p>The exec helper function was included in the psake v2.02 patch, but it bears mentioning again. If you are executing a command line program (such as msbuild.exe, aspnet_compiler.exe, pskill.exe, \u2026) rather than a PowerShell function, it will not throw an execption on failure, but return a non-zero error code. We added the exec helper function, which takes care of checking the error code and throwing an exception for command line executables.<\/p>\n<pre class=\"brush: ps;\">task Compile -depends Clean {\n  exec { msbuild Foo.sln }\n}<\/pre>\n<\/p>\n<p>You can find out more details <a href=\"http:\/\/jameskovacs.com\/2010\/02\/25\/the-exec-problem\/\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<h3>.NET 4.0 Support<\/h3>\n<p>psake still defaults to .NET Framework 3.5, but you can specify another framework to use from the command line:<\/p>\n<pre class=\"brush: ps;\"><p>invoke-psake examples\\default.ps1 -framework 4.0<\/p><\/pre>\n<p>Or from within your script:<\/p>\n<pre class=\"brush: ps;\">$framework = '4.0'\n\ntask default -depends MsBuild\n\ntask MsBuild {\n  exec { msbuild \/version }\n}<\/pre>\n<h3>64-bit Support<\/h3>\n<p>You can now specify whether you want to use 32-bit (x86) or 64-bit (x64) tools when building your projects.<\/p>\n<pre class=\"brush: ps;\">invoke-psake examples\\default.ps1 -framework 3.5x86\ninvoke-psake examples\\default.ps1 -framework 3.5x64<\/pre>\n<p>If you don\u2019t specify x86 or x64 after the framework version, psake selects the framework bitness based on whether you\u2019re running from a 32-bit or 64-bit PowerShell prompt. (On 64-bit Windows, the default PowerShell prompt is 64-bit. If you want a 32-bit prompt, launch \u201cWindows PowerShell (x86)\u201d. Valid values for the framework are &#8216;1.0&#8217;, &#8216;1.1&#8217;, &#8216;2.0&#8217;, &#8216;2.0&#215;86&#8217;, &#8216;2.0&#215;64&#8217;, &#8216;3.0&#8217;, &#8216;3.0&#215;86&#8217;, &#8216;3.0&#215;64&#8217;, &#8216;3.5&#8217;, &#8216;3.5&#215;86&#8217;, &#8216;3.5&#215;64&#8217;, &#8216;4.0&#8217;, &#8216;4.0&#215;86&#8217;, and &#8216;4.0&#215;64&#8217;.<\/p>\n<h3>psake.ps1 Helper Script<\/h3>\n<p>Because psake is a PowerShell module, you have to import the module before using it.<\/p>\n<pre class=\"brush: ps;\">import-module .\\psake.psm1\ninvoke-psake examples\\default.ps1\n# do some work\ninvoke-psake examples\\default.ps1\n# do some more work\nremove-module psake # when done, remove psake or close your PS prompt<\/pre>\n<p>If you want to use the psake.psm1 stored in a particular project\u2019s repository, you have to remember to import the correct version of psake from that project. You also need to create a ps1, bat, or cmd file for your continuous integration server so that the correct version of psake is registered to orchestrate the build. We have standardized this using a psake.ps1 helper script:<\/p>\n<pre class=\"brush: ps;\"># psake.ps1\n# Helper script for those who want to run\n# psake without importing the module.\nimport-module .\\psake.psm1\ninvoke-psake @args\nremove-module psake<\/pre>\n<p>With this script, you can now execute psake without first importing the module.<\/p>\n<pre class=\"brush: ps;\">.\\psake examples\\default.ps1 test<\/pre>\n<p>You can read about the splatting operator (@) <a href=\"http:\/\/jameskovacs.com\/2010\/03\/21\/pow-biff-wham-splat\/\" target=\"_blank\" rel=\"noopener\">here<\/a> if you\u2019re wondering what invoke-psake @args does.<\/p>\n<h3>Support for Parameters and Properties<\/h3>\n<p>Invoke-psake has two new options, \u2013parameters and \u2013properties. Parameters is a hashtable passed into the current build script. These parameters are processed before any &#8216;Properties&#8217; functions in your build scripts, which means you can use them from within your Properties.<\/p>\n<pre class=\"brush: ps;\">invoke-psake Deploy.ps1 -parameters @{server=\u2019Server01\u2019}\n\n# Deploy.ps1\nproperties {\n  $serverToDeployTo = $server\n}\n\ntask default -depends All\n\n# additional tasks<\/pre>\n<p>Parameters are great when you have required information. Properties on the other hand are used to override default values.<\/p>\n<pre class=\"brush: ps;\">invoke-psake Build.ps1 -properties @{config='Release'}\n\n# Build.ps1\nproperties {\n  $config = 'Debug'\n}\n\ntask default -depends All\n\n# additional tasks<\/pre>\n<h3>Support for Nested Builds<\/h3>\n<p>You can now invoke build scripts from within other build scripts. This allows you to break large, complex scripts into smaller, more manageable ones.<\/p>\n<pre class=\"brush: ps;\">task default -depends RunNested1, RunNested2\n\ntask RunNested1 {\n  Invoke-psake .\\nested\\nested1.ps1\n}\n\ntask RunNested2 {\n  Invoke-psake .\\nested\\nested2.ps1\n}<\/pre>\n<h3>Tab Expansion<\/h3>\n<p><a href=\"http:\/\/www.candland.net\" target=\"_blank\" rel=\"noopener\">Dusty Candland<\/a> implemented PowerShell tab expansion for psake. You can find instructions on setting up tab expansion in .\/tabexpansion\/Readme.PsakeTab.txt in the download. Once configured, you can:<\/p>\n<pre class=\"brush: ps;\">tab completion for file name: psake d&lt;tab&gt; -&gt; psake .\\default.ps1\ntab completion for parameters: psake -t&lt;tab&gt; -&gt; psake -task\ntab completion for tasks: psake -task c&lt;tab&gt; -&gt; psake -task Clean<\/pre>\n<p>You can find more details on Dusty\u2019s blog <a href=\"http:\/\/www.candland.net\/blog\/2010\/04\/08\/PsakeTabExpansion.aspx\" target=\"_blank\" rel=\"noopener\">here<\/a>. Excellent addition! Thanks, Dusty.<\/p>\n<h3>Invoke Default Script<\/h3>\n<p><a href=\"http:\/\/staxmanade.blogspot.com\/\" target=\"_blank\" rel=\"noopener\">Jason Jarrett<\/a> provided this welcome fix, which allows you to execute tasks without specifying the default build file name (default.ps1).<\/p>\n<pre class=\"brush: ps;\">invoke-psake Compile # Executes the Compile task in default.ps1<\/pre>\n<p>Previously you had to specify invoke-psake default.ps1 Compile. You could only omit default.ps1 if you were running the default task.<\/p>\n<h2>Big Thanks!<\/h2>\n<p>Thanks to everyone who contributed to this release, especially Jorge Matos who contributed many of the new features noted above. If you have any questions, please join the <a href=\"http:\/\/groups.google.com\/group\/psake-users\" target=\"_blank\" rel=\"noopener\">psake-users Google Group<\/a>. If you\u2019re interested in contributing to the ongoing development, we also have a <a href=\"http:\/\/groups.google.com\/group\/psake-dev\" target=\"_blank\" rel=\"noopener\">psake-dev Google Group<\/a>. Happy scripting, everyone!<\/p>\n<p>P.S. Wondering what happened to psake v3.00? It\u2019s chilling with its friends EF v2 and EF v3\u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is with great pleasure that I announce psake v4.00, which you can download here. The project has grown up a great deal in the last few months. More projects are using psake for orchestrating their builds and we have more developers submitting patches. I\u2019m really pleased with how psake is growing up. GitHub has [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,16],"tags":[],"class_list":["post-330","post","type-post","status-publish","format-standard","hentry","category-dotnettools","category-powershell"],"_links":{"self":[{"href":"https:\/\/www.jameskovacs.com\/index.php\/wp-json\/wp\/v2\/posts\/330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jameskovacs.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jameskovacs.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jameskovacs.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jameskovacs.com\/index.php\/wp-json\/wp\/v2\/comments?post=330"}],"version-history":[{"count":0,"href":"https:\/\/www.jameskovacs.com\/index.php\/wp-json\/wp\/v2\/posts\/330\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jameskovacs.com\/index.php\/wp-json\/wp\/v2\/media?parent=330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jameskovacs.com\/index.php\/wp-json\/wp\/v2\/categories?post=330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jameskovacs.com\/index.php\/wp-json\/wp\/v2\/tags?post=330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}