Community.VisualStudio.Toolkit
Community.VisualStudio.Toolkit copied to clipboard
add nested file in legacy style csproj does NOT working
Description
VS2019 16.11
PhysicalFile.AddNestedFileAsync is not working for legacy style csproj, at least in my https://github.com/lsoft/NestedUnitTests (see ProcessLegacyStyleProjectAsync method). Technically, it's working but I need to unload/reload project to see the new file to be nested. Without that, the file is listed at the same level in the tree.
when I switch back to
var rootDocumentItem = dte.Solution.FindProjectItem(rootDocumentItemFilePath);
rootDocumentItem.ProjectItems.AddFromFile(childDocumentItemFilePath);
I do not need to unload/reload project, the file adds as nested "automatically".
So, I see here 2 troubles/questions.
- How can the code above be re-implemented without
DTE? - Probably, we need to modify
PhysicalFile.AddNestedFileAsyncto support both types of csproj.
How to repro
- Run https://github.com/lsoft/NestedUnitTests to your Exp instance of VS.
- Open class lib with legacy styled project.
- Try to add nested file (RMB click on any regular cs file and choose latest command in the menu)
- Notice, the added file is nested.
- Replace the DTE-approach with the community SDK approach in
ProcessLegacyStyleProjectAsync. - Run vsix, and repeat the action. Notice that added file will not be nested. Unload/Reload project and the file is nested now.
Thanks for this SDK, guys. It's great!