If you are doing some stuff with Visual Studio Extensibility you may come across with this exception and it is actually pretty annoying since it’s hard to find out the reason. In my case the complete description error is:
Microsoft.VsSDK.targets(434,5): error : Exception has been thrown by the target of an invocation.
And the most important information is the one regarding to the line of the targets file (435 in my case). If you want Visual Studio to open and point it directly just look at the Output panel where the error is shown in red and double click it. Most of the times it points to UninstallExtension task:
<UninstallExtension Condition="'$(ExistingDeploymentPath)' != '$(VsixDeploymentPath)' AND '$(ExistingDeploymentPath)' != ''" VsixIdentifier="$(VsixID)" RootSuffix="$(VSSDKTargetPlatformRegRootSuffix)" FailIfNotInstalled="false" />
Tthis task is at line 434 for VS 2012 and 420 for VS2010 (although it may vary). The explanation is that your VS Addin (the one you are developing) is trying to uninstall the extension that has been probably installed with the MSI installer or VS Extension Manager. So to work around this issue you have two ways. The first one is to uninstall your VS Addin using either the Extension Manager or the MSI package (from the Control Panel) or just tell the VSIX not to deploy the plugin as is shown in the image below:
However, keep in mind that the pdb files will not be deployed and therefore you won’t be able to debug (unless you deploy them manually)
Anyway, whichever way you take, I really recommend to uninstall the VSIX in order to prevent MEF or other sort of compositions mismatches.