FileNesting icon indicating copy to clipboard operation
FileNesting copied to clipboard

Nesting removes (copy) file properties

Open obiwanjacobi opened this issue 9 years ago • 1 comments

Installed product versions

  • Visual Studio: 2015 Update 3 (Express/Community)
  • This extension: 2.5.65

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.

obiwanjacobi avatar Dec 04 '16 06:12 obiwanjacobi

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

rmaenk avatar Aug 16 '18 14:08 rmaenk