views:

593

answers:

2

Hi guys,

I need some help with my MSBuild file i created a while ago.

All i want to do is build the solution, publish a project inside the solution and than copy the files to a directory

At the moment when i set Teamcity to .net 4 msbuild, msbuild 4.0 tools and for 86 i get an error stating

error MSB4067: The element beneath element is unrecognized.


<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Run">

  <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>

  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets"/>

  <PropertyGroup>
    <OutputFolder>$(OutputDir)</OutputFolder>
    <DeploymentFolder>$(DeploymentDir)</DeploymentFolder>
    <CompilationDebug />
    <CustomErrorsMode />
    <ContentEditorsEmail />
    <AdministratorsEmail />
  </PropertyGroup>

  <Target Name="Run">
    <CallTarget Targets="Compile" />
    <CallTarget Targets="Publish" />
    <CallTarget Targets="Deploy" />
  </Target>

  <Target Name="Clean">
    <ItemGroup>
      <BinFiles Include="bin\*.*" />
    </ItemGroup>
    <Delete Files="@(BinFiles)" />
  </Target>

  <Target Name="Compile" DependsOnTargets="Clean">
    <MSBuild Projects="WebCanvas.ZakisCatering.Website.sln"
        Properties="Configuration=Release"/>
  </Target>

  <Target Name="Publish">
    <RemoveDir Directories="$(OutputFolder)" ContinueOnError="true" />
    <MSBuild Projects="WebCanvas.ZakisCatering.Website\WebCanvas.ZakisCatering.Website.csproj"
             Targets="ResolveReferences;_CopyWebApplication"
             Properties="Configuration=Release;WebProjectOutputDir=$(OutputFolder);OutDir=$(WebProjectOutputDir)\" />
  </Target>

  <Target Name="Deploy">
    <RemoveDir Directories="$(DeploymentFolder)"
               ContinueOnError="true" />
    <ItemGroup>
      <DeploymentFiles Include="$(OutputFolder)\**\*.*" />
    </ItemGroup>
    <Copy SourceFiles="@(DeploymentFiles)"
          DestinationFolder="$(DeploymentFolder)\%(RecursiveDir)" />
  </Target>

</Project>
+3  A: 

I'm getting that error code too, although complaining about a different element:

error MSB4067: The element beneath element is unrecognized.

I did notice that Teamcity is invoking the 2.0 version of MSBuild, which could explain why msbuild is struggling with the xml.

'C:\Windows\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe' '@"D:\BuildAgent\work\2f016459feee51ce\Build\BuildSolution.msbuild.teamcity.msbuild.tcargs" "D:\BuildAgent\work\2f016459feee51ce\Build\BuildSolution.msbuild.teamcity.patch.tcprojx"' working dir = 'D:\BuildAgent\work\2f016459feee51ce' Microsoft (R) Build Engine Version 2.0.50727.4016 [Microsoft .NET Framework, Version 2.0.50727.4200]

I fixed the 2.0 msbuild problem by adding to the .\conf\buildagent.properties file on the team city build agent machine, the following:

env.MSBuild=%system.DotNetFramework4.0_x86_Path%

Restart the service after that and problem solved.

FrederikB
Worked first go :D FYI for others .\conf is found in the build folder specified on install :D
ChrisKolenko
+1  A: 

Unfortunately, they don't package the WebApplications targets. I can't find an SDK that has these targets packaged without having VS installed...no way. I don't understand why MS makes CI so difficult.

SonOfNun