pemby
New member
- Joined
- Jul 27, 2021
- Messages
- 2
- Programming Experience
- 5-10
Hi, I am attempting to use Microsoft.Build.Construction to parse a few .csproj files.
I am looping over a few csproj files to build a report. I am running into the following error
Not sure why I cannot access ProjectElement.ElementName
// ComplieTime ERROR:'ProjectElement' does not contain a definition for 'ElementName'
//and no accessible extension method 'Name' accepting a first argument of type
//'ProjectElement' could be found (are you missing a using directive or an assembly reference?)
Here is a code snippet that reproduces the error.
I am looping over a few csproj files to build a report. I am running into the following error
Not sure why I cannot access ProjectElement.ElementName
// ComplieTime ERROR:'ProjectElement' does not contain a definition for 'ElementName'
//and no accessible extension method 'Name' accepting a first argument of type
//'ProjectElement' could be found (are you missing a using directive or an assembly reference?)
Here is a code snippet that reproduces the error.
C#:
using (IEnumerator<ProjectItemGroupElement> itemEnums = ProjRootEl.ItemGroups.GetEnumerator())
{
while (itemEnums.MoveNext())
{
ProjectItemGroupElement currItem = itemEnums.Current;
IEnumerator<ProjectItemElement> currItemEnums = currItem.Items.GetEnumerator();
using (currItemEnums)
{
while (currItemEnums.MoveNext())
ProjectItemElement innerItems = currItemEnums.Current;
bool someCondition = true;
if (someCondition)
{
foreach(ProjectElement child in innerItems.Children)
{
// ComplieTime ERROR:'ProjectElement' does not contain a definition for 'ElementName'
//and no accessible extension method 'Name' accepting a first argument of type
//'ProjectElement' could be found (are you missing a using directive or an assembly reference?)
string buffer = child.ElementName;
}
}
}
}
}