Have a big problem here. I can\'t open any type of project in Visual Studio. Even when I creating a new one I get the error:
the element <#text> be
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.
I had this problem due to git merge conflicts inserting invisible characters into the xml file. To fix this:
open sln file in a text editor and copy the contents into an online xml validator (https://www.xmlvalidation.com/)
find location of invisible characters and either delete them or retype the line
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 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>
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 sure is a installation error and i would suggest don't try to fix because there may be more such errors. I have seen a few of such errors during my work with partners and mostly these errors are caused by botched installation due to real-time, virus scanner or some unknown issues in the machine.
Here is what I could suggest:
It worked in past so I hope it will work with you as well.