TeamCity:无法检测 MSBuild 项目中的目标
我认为 TeamCity MSBuild 替代品存在一些问题。
我尝试使用 MSBuild 任务 (NAnt Contrib) 编译 Delphi 2010 项目(兼容 MSBuild)。
如果我在控制台上没有 TeamCity 的情况下执行此操作,则一切正常。
如果我尝试使用 TeamCity,则会收到以下错误消息:
Failed to detect default target(s) in the project file F:\CI\TeamCity\TeamCity\buildAgent\work\892195dab42324a3\build\src.temp\TestProject\Test.dproj. Please define targets explicitly in the build configuration options on TeamCity Web UI. Project does not define DefaultTargets or InitialTargets.
我尝试通过指向重建目标的 MSBuild /target 开关显式设置目标。到目前为止还没有运气。
有什么建议吗?提前致谢。
编辑:
<foreach item="File" property="iterator.dproj">
<in>
<items>
<include name="${src.temp}\**\*.dproj" />
</items>
</in>
<do>
<msbuild project="${iterator.dproj}">
<arg value="/target:Rebuild" />
</msbuild>
</do>
</foreach>
*.dproj 文件是一个标准的 delphi 2010 项目文件(它是用 xsl 转换的,但它仍然是一个有效的项目文件)
Edit2:
感谢 s。 ermakovich,我用直接调用 NAnt 替换了 msbuild 任务(来自 NAnt contrib),这不会在 TeamCity 服务器上产生错误。看起来 TeamCity 只替换了对 NAnt contrib msbuild 任务的调用。 :-)
<property name="msbuild.exe" value="${framework::get-framework-directory(nant.settings.currentframework)}\msbuild.exe" />
<foreach item="File" property="iterator.dproj">
<in>
<items>
<include name="${src.temp}\**\*.dproj" />
</items>
</in>
<do>
<exec program="${msbuild.exe}">
<arg path="${iterator.dproj}" />
</exec>
</do>
</foreach>
I have some problems with the TeamCity MSBuild replacement I think.
I've tried to compile a Delphi 2010 Project (MSBuild compliant) with NAnt using the MSBuild task (NAnt Contrib).
Everything works fine, if I do it without TeamCity on the console.
If I try it with TeamCity, I get the following error message:
Failed to detect default target(s) in the project file F:\CI\TeamCity\TeamCity\buildAgent\work\892195dab42324a3\build\src.temp\TestProject\Test.dproj. Please define targets explicitly in the build configuration options on TeamCity Web UI. Project does not define DefaultTargets or InitialTargets.
I've tried to explicitly set the target via the MSBuild /target switch pointing to the Rebuild target. So far no luck.
Any Suggestions? Thanks in advance.
Edit:
<foreach item="File" property="iterator.dproj">
<in>
<items>
<include name="${src.temp}\**\*.dproj" />
</items>
</in>
<do>
<msbuild project="${iterator.dproj}">
<arg value="/target:Rebuild" />
</msbuild>
</do>
</foreach>
The *.dproj file is a standard delphi 2010 project file (it's transformed with xsl but it's still a valid project file)
Edit2:
Thanks to s. ermakovich, I replaced the msbuild task (from NAnt contrib) with the direct call to NAnt, which does not produce the error on TeamCity server. Looks like TeamCity does only replace the call to NAnt contrib msbuild task. :-)
<property name="msbuild.exe" value="${framework::get-framework-directory(nant.settings.currentframework)}\msbuild.exe" />
<foreach item="File" property="iterator.dproj">
<in>
<items>
<include name="${src.temp}\**\*.dproj" />
</items>
</in>
<do>
<exec program="${msbuild.exe}">
<arg path="${iterator.dproj}" />
</exec>
</do>
</foreach>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您似乎在控制台命令行中使用 /target 开关。请尝试在 TeamCity Web UI 上的构建配置选项中指定您需要的目标,如错误消息所建议的那样。您可以在 TeamCity 项目配置的 Runner 选项卡上找到此参数。输入以空格或分号分隔的目标。默认情况下支持构建、重建、清理、发布目标。
It seems that you are using /target switch in your console command line. Please, try to specify target(s) that you need in the build configuration options on TeamCity Web UI, as it is suggested by the error message. Yon can find this parameter on the Runner tab of the TeamCity project configuration. Enter targets separated by space or semicolon. Build, Rebuild, Clean, Publish targets are supported by default.
我在VS2017中创建项目时遇到了这个问题。它将项目添加为 TooVersion="15.0",并且没有 DefaultTargets 属性。我在 2015 年更改了它,因为我的团队城市 msbuild 选项是 2015。所以现在两者同步
I encountered this issue while creating the project in VS2017. It added the project as TooVersion="15.0" and there is no DefaultTargets attribute. I changed it 2015 since my team city msbuild option is 2015. So both now sync
您可以确保在
标记中定义DefaultTargets="..."
,而不是在命令行或 teamcity 中指定构建目标。项目文件。Rather than specifying the build target on the command line or in teamcity, you can ensure that
DefaultTargets="..."
is defined on the<Project>
tag in the project file.