Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TeamCity MSBuild 4.0 Help

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 <ItemDefinitionGroup> beneath element <Project> 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>
like image 254
Chris Kolenko Avatar asked Jan 23 '23 06:01

Chris Kolenko


2 Answers

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

error MSB4067: The element <ArtifactAssemblies> beneath element <ItemGroup> 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.

like image 145
Frederik Avatar answered Jan 24 '23 19:01

Frederik


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.

like image 40
SonOfNun Avatar answered Jan 24 '23 19:01

SonOfNun