visual studio 2013 - Post-build Error when using gacutil and installutil to deploy powershell snapin -


I have a VS I am trying to learn how to write snapin for PowerShell 4.0 using the 2013. The script is very simple and is compiled with no errors. However, when I added gacutil and installutil to deploy snapin using post-built, I got this error:

  error 1 command "" C: \ program files (x86 ) \ Microsoft SDKs \ Windows \ v8.1A \ bin \ NETFX 4.5.1 Tools \ x64 \ gacutil.exe "-if" Tools.Powershell.Printscreen.dll "" C: \ Windows \ Microsoft.NET \ Framework64 \ v4. 0.30319 \ InstallUtil.exe "" Tools.Powershell.Printscreen.dll "" exited code -1  

However, if I have copied the commands and run it from the command prompt , Both commands Successfully run and the establishment was successfully deployed. I can then add snapins to the powers, snapin ran successfully.

I checked and used the framework correctly 4.5.1, VS 2013, the system is Windows 8.1

There are post-build commands:

  "C: \ Program Files (x86) \ Microsoft SDKs \ Windows \ v8.1A \ bin \ NETFX 4.5.1 Tools \ x64 \ gacutil.exe" - If "$ (TargetPath)" "C: \ Windows \ Microsoft.NET \ Framework 64 \ v4.0.30319 \ InstallUtil.exe "" $ (target) " 

I think code for snapin at this point is irrelevant but if you want to include me Please tell me, I believe that This is going to affect the solution at this point, BC is the easiest and it worked after manually deploying it using the command prompt.

Please advise.

Thank you!

Why not create a snapin unless you need to target V1, which you can not do If you are compiling with .NET 4.5.1 I would recommend using a module . There is no registration / installation required. You simply expose the module of the target system ($ home \ Documents \ WindowsPowerShell \ Modules) and use it. I would suggest that you create a PSD1 manifest file for your module. Root Module The name of your DLL will be: Tools.Powershell.Printscreen.dll. See new-modemmenest commands to help create the PSD1 file. To identify this module uniquely, there is basic material like author's name, version, GUID, etc. I also recommend that you list your exported CMDlet in the CmdletsToExport field. It will speed up the processing to automatically load the modules.

And in a pinch, for testing purposes, you can import directly DLL (without making a PSD1 file):

  Import-module -Script c: \ Temp \ Tools.Powershell.Printscreen.dll  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -