12

我有一个项目,它有一个构建后事件,将 DLL 复制到某个目录:

xcopy "$(TargetDir)$(TargetName).dll" "$(SolutionDir)..\UdpLocationService\bin\Plugins\" /d /y
xcopy "$(TargetDir)$(TargetName).pdb" "$(SolutionDir)..\UdpLocationService\bin\Plugins\" /d /y

但是,我将 CruiseControl.NET 设置为构建服务器,并且由于此 xcopy 构建后事件,MSBuild 无法构建该项目:

MSB3073: The command "xcopy "C:\Build\Services\Windows\VehicleServer\Plugins\Payload\bin\Debug\Payload.dll" "*Undefined*..\UdpLocationService\bin\Plugins\" /d /y xcopy "C:\Build\Services\Windows\VehicleServer\Plugins\Payload\bin\Debug\Payload.pdb" "*Undefined*..\UdpLocationService\bin\Plugins\" /d /y" exited with code 4. in Microsoft.Common.targets(3397, 13)

有什么建议可以解决这个问题吗?

4

3 回答 3

26

我刚刚遇到了与 TeamCity 相同的问题。

这里的问题是构建文件中的 $(SolutionDir) 属性。您尚未在对 MsBuild 的调用中定义它(这就是您在输出中看到未定义一词的原因)。

使用属性集调用 msbuild,如下所示:

msbuild myproject.csproj /property:SolutionDir="solution directory"\

其中“解决方案目录”是包含您的解决方案文件的目录。请注意尾部的斜杠,您需要它来确保路径格式正确。

于 2012-02-15T18:11:09.937 回答
8

我通过添加以下内容解决了 Microsoft.SqlServer.Compact nuget 包(添加了类似的构建后脚本)的问题:

<SolutionDir Condition="'$(SolutionDir)'=='' or '$(SolutionDir)'=='*Undefined*'">..\</SolutionDir>

就在<PostBuildEvent>. 您需要调整相对路径以匹配您的项目布局。

于 2013-08-09T17:53:00.587 回答
4

跟着这些步骤:

  • 卸载您的项目文件(例如 *.csproj)
  • 打开您的项目文件进行编辑
  • 找到 AfterBuild 目标
  • 将 XCopy 的两次调用分离为两个不同的 Exec 任务
  • 保存您的更改并重新加载您的项目文件
于 2010-07-01T20:01:48.027 回答