Windows 7上执行Cake 报错原因是Powershell 版本问题

在Windows 7 SP1 电脑上执行Cake的的例子 http://cakebuild.net/docs/tutorials/getting-started ,运行./Build.ps1 报下面的错误

PS D:\Workshop\GitHub\cakebuildexample> ./build.ps1 -Target Default

Preparing to run build script...

Join-Path : 无法将参数绑定到参数“Path”,因为该参数是空值。

所在位置 D:WorkshopGitHubcakebuildexamplebuild.ps1:50 字符: 23

  • $TOOLS_DIR = Join-Path <<<< $PSScriptRoot "tools"
  • CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
  • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCom

mand

Join-Path : 无法将参数绑定到参数“Path”,因为该参数是空值。

所在位置 D:WorkshopGitHubcakebuildexamplebuild.ps1:51 字符: 23

  • $NUGET_EXE = Join-Path <<<< $TOOLS_DIR "nuget.exe"
  • CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
  • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCom

mand

Join-Path : 无法将参数绑定到参数“Path”,因为该参数是空值。

所在位置 D:WorkshopGitHubcakebuildexamplebuild.ps1:53 字符: 22

  • $CAKE_EXE = Join-Path <<<< $TOOLS_DIR "Cake/Cake.exe"
  • CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
  • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCom

mand

Join-Path : 无法将参数绑定到参数“Path”,因为该参数是空值。

所在位置 D:WorkshopGitHubcakebuildexamplebuild.ps1:54 字符: 29

  • $PACKAGES_CONFIG = Join-Path <<<< $TOOLS_DIR "packages.config"
  • CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
  • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCom

mand

Test-Path : 无法将参数绑定到参数“Path”,因为该参数是空值。

所在位置 D:WorkshopGitHubcakebuildexamplebuild.ps1:77 字符: 15

  • if ((Test-Path <<<< $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
  • CategoryInfo : InvalidData: (:) [Test-Path], ParameterBindingValidationException
  • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.TestPathCom

mand

Test-Path : 无法将参数绑定到参数“Path”,因为该参数是空值。

所在位置 D:WorkshopGitHubcakebuildexamplebuild.ps1:83 字符: 16

  • if (!(Test-Path <<<< $PACKAGES_CONFIG)) {
  • CategoryInfo : InvalidData: (:) [Test-Path], ParameterBindingValidationException
  • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.TestPathCom

mand

Test-Path : 无法将参数绑定到参数“Path”,因为该参数是空值。

所在位置 D:WorkshopGitHubcakebuildexamplebuild.ps1:91 字符: 16

  • if (!(Test-Path <<<< $NUGET_EXE)) {
  • CategoryInfo : InvalidData: (:) [Test-Path], ParameterBindingValidationException
  • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.TestPathCom

mand

Test-Path : 无法将参数绑定到参数“Path”,因为该参数是空值。

所在位置 D:WorkshopGitHubcakebuildexamplebuild.ps1:102 字符: 16

  • if (!(Test-Path <<<< $NUGET_EXE)) {
  • CategoryInfo : InvalidData: (:) [Test-Path], ParameterBindingValidationException
  • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.TestPathCom

mand

Set-Location : 无法处理参数,因为参数“path”的值为空。请将参数“path”的值更改为非空值。

所在位置 D:WorkshopGitHubcakebuildexamplebuild.ps1:119 字符: 17

  • Set-Location <<<< $TOOLS_DIR
  • CategoryInfo : InvalidArgument: (:) [Set-Location], PSArgumentNullException
  • FullyQualifiedErrorId : ArgumentNull,Microsoft.PowerShell.Commands.SetLocationCommand

管道元素中“&”后的表达式生成的对象无效。该表达式必须生成命令名称、脚本块或 CommandInfo 对象。

所在位置 行:1 字符: 2

  • & <<<< "" install -ExcludeVersion -OutputDirectory ""
  • CategoryInfo : InvalidOperation: (:String) [], RuntimeException
  • FullyQualifiedErrorId : BadExpression

Test-Path : 无法将参数绑定到参数“Path”,因为该参数是空值。

所在位置 D:WorkshopGitHubcakebuildexamplebuild.ps1:133 字符: 16

  • if (!(Test-Path <<<< $CAKE_EXE)) {
  • CategoryInfo : InvalidData: (:) [Test-Path], ParameterBindingValidationException
  • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.TestPathCom

mand

Running build script...

管道元素中“&”后的表达式生成的对象无效。该表达式必须生成命令名称、脚本块或 CommandInfo 对象。

所在位置 行:1 字符: 2

  • & <<<< "" "build.cake" -target="Default" -configuration="Release" -verbosity="Verbose"
  • CategoryInfo : InvalidOperation: (:String) [], RuntimeException
  • FullyQualifiedErrorId : BadExpression

上述报错有很多,问题的根源是PowerShell的版本问题,查了下我机器上是2.0版本的

PS D:WorkshopGitHubcakebuildexample> $PSVersionTable.PSVersion

Major Minor Build Revision

----- ----- ----- --------

2 0 -1 –1

解决办法就是升级(建议升级3.0 能够成功解决),Windows Management Framework 3.0 下载地址:https://www.microsoft.com/en-us/download/details.aspx?id=34595 ,安装后就可以成功执行了。

本文来自云栖社区合作伙伴“doNET跨平台”,了解相关信息可以关注“opendotnet”微信公众号

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值