Reputation: 1087
I'm trying to run a powershell script when doing a file system publish for my project in Visual Studio, but snap-ins don't seem to be working when actually running the publish.
If I run the powershell script manually outside of visual studio the snap-in works fine, but when its executed via the publish it doesn't work.
Here is the target in the .pubxml profile.
<Target Name="Test" AfterTargets="GatherAllFilesToPublish">
<Message Text="********************************** Test ***********************************" Importance="high" />
<Exec Command="powershell.exe -file "$(ProjectDir)\Properties\PublishProfiles\test.ps1" $(ProjectDir)"/>
</Target>
And here is the powershell script
Add-PSSnapin Microsoft.TeamFoundation.PowerShell
$changeset = Get-TfsItemHistory $filePath -Recurse -StopAfter 1 | Select -ExpandProperty ChangesetId
Which results in
Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.TeamFoundation.PowerShell' is not installed on this computer.
Im also open to not using a snap-in if a alternative exists for the Get-TfsItemHistory
command.
Upvotes: 0
Views: 350
Reputation: 3421
I have no personal experience of this snap-in myself but here are some thoughts at least:
Add-PSSnapin
and see if you can reproduce the errorGet-PSSnapin
in the publish. Most likely it's not there but you can add it using the installutil.exe
command.
Upvotes: 1