我有一个项目,它有一个构建后事件,可以将 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)
有什么建议可以解决这个问题吗?
我刚刚在 TeamCity 中遇到了同样的问题。
这里的问题是构建文件中的 $(SolutionDir) 属性。您尚未在对 MsBuild 的调用中定义它(这就是您在输出中看到单词 undefined 的原因)。
使用属性集调用 msbuild,如下所示:
msbuild myproject.csproj /property:SolutionDir="solution directory"\
其中“解决方案目录”是包含解决方案文件的目录。请注意尾部斜杠,您需要它来确保路径格式正确。
我通过添加以下内容修复了 Microsoft.SqlServer.Compact nuget 包(添加了类似的构建后脚本)的问题:
<SolutionDir Condition="'$(SolutionDir)'=='' or '$(SolutionDir)'=='*Undefined*'">..\</SolutionDir>
就在
<PostBuildEvent>
上方。您需要调整相对路径以匹配您的项目布局。
请按照以下步骤操作:
我遇到了同样的问题,Philippe Mar 提供的解决方案解决了这个问题。谢谢菲利普·马尔。