I am trying to write a powershell script to reload a project (files and folders have been added to it via a C# app (tried to do this via C# but failed, see here). My end goal is to be able to call the C# app then reload the project (unload and reload) to refresh the project and avoid the user having to manually say reload the project.
$project = Get-Project
write-host("starting NHMigrate on project: " + $project.Name)
$project.FullName
$project.UniqueName
$shortpath = $dte.Solution.Properties.Item("Name").Value + "\" + $project.Name
$dte.Windows.Item("{3AE79031-E1BC-11D0-8F78-00A0C9110057}").Activate()
$dte.ActiveWindow.Object
$dte.ActiveWindow.Object.GetItem($project.UniqueName)
The problem I am having is everything I google says use GetItem to select that project to be able to call execute_command, but I get the exception
Exception calling "GetItem" with "1" argument(s): "Value does not fall within the expected range."
At E:\Work\nhibernateRepo\NHibernateRepository\NHMigrate\test.ps1:12 char:1
+ $dte.ActiveWindow.Object.GetItem($project.UniqueName)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentException
I can't find anything on why this doesn't work. Everyone seems to be calling get Item with a single param. Ican't find the docs that covers this method either.
EDIT
This is a note about what I was trying to achieve. Using powershell to refresh the project works but it doesn't stop, or remove the "File Modification Detected" dialog which was ultimately what I wanted to do.