The element <#text> beneath element <Target> is unrecognized in Azure

There will be a Typo in the .csProject. You can copy and paste the csProj XML into https://freeformatter.com/xml-formatter.html and it will show what line is causing the problem!


This also happens with generic XML errors. In my case it was >> somewhere in the project file. Was a copy-paste error during conflict resolution that introduced it. Sadly, the output does not include the line that has the error, so try searching for << and >> in the file, to see if that is an issue somewhere.


This also happens if a Property, that should be under a <PropertyGroup> node is a child of a <Target> node

wrong (produces the error):

<Project ToolsVersion="15.0" DefaultTargets="CalculateVariables" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="CalculateVariables">
    <IsWrong>true</IsWrong>
  </Target>
</Project>

right (works):

<Project ToolsVersion="15.0" DefaultTargets="CalculateVariables" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="CalculateVariables">
    <PropertyGroup>
      <IsWrong>true</IsWrong>
    <PropertyGroup>
  </Target>
</Project>

I faced this problem too. The error text was:

The element <#text> beneath element <Target> is unrecognized.
c:\Program Files (x86)\MSBuild\12.0\Bin\Microsoft.CSharp.CurrentVersion.targets

The solution for me was to check the indicated file against a working one from one of my coleagues. Even an XML parser or even a browser would pop-up an error when faced to this sort of error. A element under <Target> was corrupt. Instead of <Csc ... /> I had exactly 07sc ... />. I fixed formatting and It worked. Mind you that the file indicated in the error text (Microsoft.CSharp.CurrentVersion.targets) was the guilty one. Hope this helps.