Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TeamCity: Failed to detect target in MSBuild project

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>
like image 621
Dennis Avatar asked Oct 28 '10 08:10

Dennis


1 Answers

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.

like image 140
s.ermakovich Avatar answered Nov 10 '22 00:11

s.ermakovich