BoolBySigma / UpdateNetCorePackageInfo

SORRY THIS IS NO LONGER MAINTAINED
1 stars 0 forks source link

Multiple PropertyGroups #3

Open SGStino opened 7 years ago

SGStino commented 7 years ago

If the project contains multiple property groups, the xmlmapper will have it as an Array.

var properties = file.Project.PropertyGroup;

properties here will be an array of propertygroup objects.

I suggest finding the first PropertyGroup without condition attribute on it and using that to set the properties on. Should be correct in most cases. Only when package metadata is set inside a conditional it won't find it. However, in that case I don't believe this script should be able to update it anyway.

var properties = file.Project.PropertyGroup;
if(properties.constructor === Array) // there might be multiple property groups in the csproj
{
    var propCount = properties.length;
    for(var i = 0; i < propCount; i++)
    {
        if(properties[i].Condition === undefined) // if there is no condition, we can use this property group
        {
            properties = properties[i];
            break;
        }
    } 
}
sarvasana commented 6 years ago

The thing could set all elements in all property groups regardless of the condition attribute. Maybe use xpath instead?

//PropertyGroup/Version //PropertyGroup/Authors etc...

The structure is always:

<Project>
 <PropertyGroup>

</PropertyGroup>
</Project>

Who cares if the Version or other attributes are present in two PropertyGroups?