madskristensen / FileNesting

Nest files in Solution Explorer
Other
119 stars 59 forks source link

Nesting removes (copy) file properties #66

Open obiwanjacobi opened 7 years ago

obiwanjacobi commented 7 years ago

Installed product versions

Description

When file properties are set, for instance copy-if-newer and the file is nested, the configured properties are reset. I think the build action is preserved.

Steps to recreate

  1. Set the Copy-to-output-directory of any file a (C#) project to copy-if-newer
  2. Manually nest the file under another file
  3. Check the Copy-to-output-directory property: it has reset to do-not-copy.

Current behavior

It seems that in nesting the file and therefor changing the project file, any existing child elements in the project xml for that file are removed/overwritten when the DependsOn tag is added.

Expected behavior

I would expect the file properties are preserved when moving and nesting files.

rmaenk commented 6 years ago

This occurs due the next code in ManualNester.cs file:

                bool mayNeedAttributeSet = item.ContainingProject.IsKind(ProjectTypes.DOTNET_Core, ProjectTypes.UNIVERSAL_APP, ProjectTypes.SHARED_PROJECT);

                if (mayNeedAttributeSet)
                {
                    SetDependentUpon(item, parent.Name);
                }
                else
                {
                    item.Remove();
                    parent.ProjectItems.AddFromFile(path);
                }

It would be better to avoid removing and adding file again to a project and instead just add/remove DependenUpon node. This will allow to store any standard/custom properties unchanged. I guess that for UnNest method it should work similar - currently it MAKES A COPY OF FILE (!!!), which is not needed. Regards, Roman