In Solution Explorer 'DependentUpon' project items are normally disabled as children of the other item (ex. web.config / web.Debug.config). The problem I have is when items are dynamically added via nuget/powershell at package install, Solution Explorer doesn't reload the project so the items don't show as dependent. Manually closing and reopening the solution or unload/reload the project fix the issue. I'd like to automate the Project Reload as part of the install.ps1 powershell script but when I do this I get 'Project Unloaded' errors and nuget rolls back the install. I think this is because the only way I know how to get the Reload context menu is to unload the project first.
I'm looking for the object that gets invoked behind this call. I think if I could execute directly, I wouldn't have to Unload the project first.
$dte.ExecuteCommand("Project.ReloadProject")
And here is the full code to unload/reload the project in Solution Explorer
# Reload a project thru dte/SolutionExplorer Window
# using Unload and Reload Context Menus.
$project = Get-Project
$shortpath = $dte.Solution.Properties.Item("Name").Value + "\" + $project.Name
#following GUID = Constants.vsWindowKindSolutionExplorer
#magic 1 = vsUISelectionType.vsUISelectionTypeSelect
$dte.Windows.Item("{3AE79031-E1BC-11D0-8F78-00A0C9110057}").Activate()
$dte.ActiveWindow.Object.GetItem($shortpath).Select(1)
$dte.ExecuteCommand("Project.UnloadProject")
$dte.ExecuteCommand("Project.ReloadProject")
Similar question answered here: Is there a setting in VS 2010 that will allow it to recover open files after a project file changes? However, it doesn't indicate that reload can be called without first calling unload and it doesn't provide a mechanism for calling directly w/o going thru dte.executecommand.