I've seen a bunch of similar questions, but still cannot figure out how to resolve it: I have a simple powershell cmdlet (which just adds to parameters) and a snapin to register it. The problem is then I try to run installutil I get
No public installers with the RunInstallerAttribute.Yes attribute could be found
Code for snapin:
using System.ComponentModel;
using System.Management.Automation;
namespace Cmdtlets
{
[RunInstaller(true)]
class BugBoxSnapin : PSSnapIn
{
}
}
I know that there exist 64 a 32 bit versions of installutil as well as x86 and x64 powershells. My configuration is - 64 bit machine, platform target "Any CPU", .NET Framework 4.5. I could not reference System.Management.Automation from visual studio reference selector, so I manually changed csproj file with
<Reference Include="System.Management.Automation" />
Which version of installutil should I run in which version of powershell? (I think I tried every combination but still get the same problem).
One more question: after this works I will need to interact with 32 bit COM object, how should I setup the project?
If you are targeting PowerShell V1/V2 then you should target .NET 2.0. If you're targeting V3/V4 you should be targeting .NET 4.0. If you don't have to support V1, then don't use a snapin in at all. Your binary can remain the same except that you do not need a PSSnapin class and you don't need to run installutil. You just load it either via absolute path:
Import-Module -Path c:\temp\mybinary.dll
Or if you put the dll in the Modules dir (~\Documents\WindowsPowerShell\Modules\MyBinary\MyBinary.dll), just by name:
Import-Module MyBinary