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>
</for开发者_StackOverflow社区each>
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.
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
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
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.
精彩评论