recursively add projects to a solution via powershell fails
-
Wednesday, January 19, 2011 12:16 AM
Hi I've found a powershell script to recursively add all projects to one solution. However I get this error:
PS C:\work\play> .\addtosln.ps1
You cannot call a method on a null-valued expression.
At C:\work\play\addtosln.ps1:8 char:66
+ (gci -Recurse -Filter *.*proj) | % { $dteObj.Solution.AddFromFile( <<<< $_.FullName, $false) }
You cannot call a method on a null-valued expression.
At C:\work\play\addtosln.ps1:8 char:66
+ (gci -Recurse -Filter *.*proj) | % { $dteObj.Solution.AddFromFile( <<<< $_.FullName, $false) }You cannot call a method on a null-valued expression.
At C:\work\play\addtosln.ps1:10 char:24
+ $dteObj.Solution.SaveAs( <<<< (Join-Path $scriptDirectory 'All.sln') )
Exception calling "Quit" with "0" argument(s): "The message filter indicated that the application is busy. (Exception f
rom HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))"
At C:\work\play\addtosln.ps1:12 char:13
+ $dteObj.Quit( <<<< )Here's the script I have. I've had others in my office who can run this without issue but I'm getting stuck. Anyone know what my issue is?
$scriptDirectory = (Get-Item $MyInvocation.MyCommand.Path).Directory.FullName $dteObj = New-Object -ComObject "VisualStudio.DTE" $slnDir = ".\" $slnName = "All2" $dteObj.Solution.Create($scriptDirectory, $slnName) (gci -Recurse -Filter *.*proj) | % { $dteObj.Solution.AddFromFile($_.FullName, $false) } $dteObj.Solution.SaveAs( (Join-Path $scriptDirectory 'All.sln') ) $dteObj.Quit()
All Replies
-
Friday, January 21, 2011 3:27 PMHello your problem comes from your solution name. The name you have used to create your solution is different from the name you use to save them.
By the way can you tell me how do you execute your powershell from your Guidance Package?
JiPe -
Monday, March 07, 2011 10:52 PM
I only just recently got back on this task again. Setting the name the same in both places didn't help. Here's what I get now:
PS C:\work\play> .\addtosln.ps1
Method invocation failed because [System.__ComObject] doesn't contain a method
named 'Create'.
At C:\work\play\addtosln.ps1:7 char:24
+ $dteObj.Solution.Create( <<<< $scriptDirectory, $slnName)You cannot call a method on a null-valued expression.
At C:\work\play\addtosln.ps1:10 char:24
+ $dteObj.Solution.SaveAs( <<<< (Join-Path $scriptDirectory 'All3.sln') )
Exception calling "Quit" with "0" argument(s): "The message filter indicated th
at the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCA
LL_RETRYLATER))"
At C:\work\play\addtosln.ps1:12 char:13
+ $dteObj.Quit( <<<< )

