【问题标题】:Build C# .NET 3.5 project fails with psake but succeeded with msbuild构建 C# .NET 3.5 项目因 psake 失败,但使用 msbuild 成功
【发布时间】:2013-07-11 13:12:10
【问题描述】:

我正在尝试使用 psake 为我们公司在 .NET 3.5 中的 C# 项目创建构建脚本,但是当我运行它时,它失败并出现错误

default parameter specifiers are not permitted

我用谷歌搜索,看起来这是 .NET 3.5 的问题,它不允许函数中的默认参数。

但是奇怪的是,用 msbuild.exe 构建的同一个项目却成功了。我尝试将 psake 的 $framework 变量设置为 '3.5x86' 和 '3.5x64' 但没有任何帮助。

您是否知道 psake 出了什么问题,或者我是否缺少一个秘密变量?

我的psake脚本:

$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent

$framework = '3.5x86'

$serverSln = $scriptDir+'\..\Server\Server.sln'
$clientSln = $scriptDir+'\..\Client\Client.sln'
$outDirServer = $scriptDir+'\..\Binaries\Server'
$outDirClient = $scriptDir+'\..\Binaries\Client'


task default -depends Full
task Full -depends Clean, BuildServer, BuildClient #, BuildAccs, DeployRelease

task BuildServer {
  #Framework '3.5'
  exec { msbuild $serverSln /t:Build /p:Configuration=Release /v:quiet }
}

task BuildClient {

  #Framework '3.5'
  exec { msbuild $clientSln /t:Build /p:Configuration=Deploy /v:quiet }
  exec { msbuild $clientSln /t:Build /p:Configuration=Release /v:quiet }
}

task Clean {
  Write-Host Cleaning

  if (Test-Path $outDirClient) 
    {   
        rd $outDirClient -rec -force | out-null
    }

  if (Test-Path $outDirServer) 
    {   
        rd $outDirServer -rec -force | out-null
    }
}

脚本输出:

$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent

$framework = '3.5x86'

$serverSln = $scriptDir+'\..\Server\Server.sln'
$clientSln = $scriptDir+'\..\Client\Client.sln'
$outDirServer = $scriptDir+'\..\Binaries\Server'
$outDirClient = $scriptDir+'\..\Binaries\Client'


task default -depends Full
task Full -depends Clean, BuildServer, BuildClient #, BuildAccs, DeployRelease

task BuildServer {
  #Framework '3.5'
  exec { msbuild $serverSln /t:Build /p:Configuration=Release /v:quiet }
}

task BuildClient {

  #Framework '3.5'
  exec { msbuild $clientSln /t:Build /p:Configuration=Deploy /v:quiet }
  exec { msbuild $clientSln /t:Build /p:Configuration=Release /v:quiet }
}

task Clean {
  Write-Host Cleaning

  if (Test-Path $outDirClient) 
    {   
        rd $outDirClient -rec -force | out-null
    }

  if (Test-Path $outDirServer) 
    {   
        rd $outDirServer -rec -force | out-null
    }
}

【问题讨论】:

    标签: deployment msbuild .net-3.5 psake


    【解决方案1】:

    $framework 变量在最新版本中已弃用,您应该改用framework 函数。但它显然不起作用。它看起来像 PSake 中的一个错误。

    【讨论】:

      【解决方案2】:

      我终于在键盘和椅子之间发现了一个错误。在我删除了由 .NET 4.0 创建的项目的 obj 文件后,MSBuild.exe 一直因相同的错误而失败。所以psake中没有错误,它仍然很棒:)

      【讨论】:

      • 看起来在理解构建方面存在问题。 VS 正在使用 MSSBuild 4.0 和目标 3.5 构建项目。我使用了 msbuild 3.5,这让我很困惑。更多可以在这里找到:stackoverflow.com/questions/4315057/…
      猜你喜欢
      • 2020-12-06
      • 2014-08-18
      • 2019-06-18
      • 1970-01-01
      • 2018-05-06
      • 2017-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多