{"id":13706404,"url":"https://github.com/mmaitre314/PowerShellGet-Test-Binary-Module","last_synced_at":"2025-05-05T20:31:08.407Z","repository":{"id":84184591,"uuid":"54367290","full_name":"mmaitre314/PowerShellGet-Test-Binary-Module","owner":"mmaitre314","description":"Example of PowerShellGet Binary Module","archived":false,"fork":false,"pushed_at":"2016-03-21T17:39:26.000Z","size":20,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-03T22:17:18.507Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmaitre314.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-03-21T07:10:13.000Z","updated_at":"2023-06-13T17:08:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"584d8323-a2e1-4244-996d-34220cd86635","html_url":"https://github.com/mmaitre314/PowerShellGet-Test-Binary-Module","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmaitre314%2FPowerShellGet-Test-Binary-Module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmaitre314%2FPowerShellGet-Test-Binary-Module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmaitre314%2FPowerShellGet-Test-Binary-Module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmaitre314%2FPowerShellGet-Test-Binary-Module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmaitre314","download_url":"https://codeload.github.com/mmaitre314/PowerShellGet-Test-Binary-Module/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224465817,"owners_count":17315882,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T22:00:55.125Z","updated_at":"2024-11-13T14:30:58.961Z","avatar_url":"https://github.com/mmaitre314.png","language":"C#","readme":"[![PowerShellGet package](http://mmaitre314.github.io/images/nuget.png)](https://www.powershellgallery.com/packages/PowerShellGet-Test-Binary-Module/)\n\nA minimalist example of [PowerShell binary module](https://msdn.microsoft.com/en-us/library/dd878342(v=vs.85).aspx) (.NET DLL) that can be published to the [PowerShell gallery](https://www.powershellgallery.com/) as [PowerShellGet](https://technet.microsoft.com/library/dn807169.aspx) package (aka NuGet).\n\nTo install the package, run:\n\n```\nInstall-Module -Name PowerShellGet-Test-Binary-Module -Scope CurrentUser\n```\n\nThe module contains a single `Write-HelloWorld` cmdlet, whose name is self-explanatory:\n\n```\nusing System.Management.Automation;\n\n[Cmdlet(VerbsCommunications.Write, \"HelloWorld\")]\npublic class HelloWorldCmdlet : Cmdlet\n{\n    protected override void BeginProcessing()\n    {\n        WriteObject(\"Hello, World!\");\n    }\n}\n```\n\n(the `System.Management.Automation` reference is found at `c:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\WindowsPowerShell\\3.0\\System.Management.Automation.dll`)\n\nThe module manifest stores NuGet-style package info:\n\n```\n@{\n    RootModule = 'PowerShellGet-Test-Binary-Module.dll'\n    ModuleVersion = '1.0.0.3'\n    CmdletsToExport = '*'\n    GUID = '95ee4cf1-d508-45a8-9680-203b71453f98'\n    DotNetFrameworkVersion = '4.5.1'\n    Author = 'Matthieu Maitre'\n    Description = 'Example of PowerShellGet Binary Module'\n    CompanyName = 'None'\n    Copyright = '(c) 2016 Matthieu Maitre. All rights reserved.'\n    PrivateData = @{\n        PSData = @{\n            ProjectUri = 'https://github.com/mmaitre314/PowerShellGet-Test-Binary-Module'\n            LicenseUri = 'https://github.com/mmaitre314/PowerShellGet-Test-Binary-Module/blob/master/LICENSE'\n            ReleaseNotes = ''\n        }\n    }\n}\n```\n\nAnd a couple of scripts (`Publish-ToTestRepo.ps1`, `Publish-ToPowerShellGallery.ps1`) automate publication.\n\nUnit-testing cmdlets requires a couple of tricks:\n- The PowerShell host needs to be mocked (`ICommandRuntime`)\n- Protected methods need to be accessed using `PrivateObject`\n\n```\n[TestMethod]\npublic void Test()\n{\n    var mock = new Mock\u003cICommandRuntime\u003e();\n\n    var cmdlet = new HelloWorldCmdlet\n    {\n        CommandRuntime = mock.Object\n    };\n    new PrivateObject(cmdlet).Invoke(\"BeginProcessing\");\n\n    mock.Verify(runtime =\u003e runtime.WriteObject(\"Hello, World!\"), Times.Once);\n}\n```\n\nThis code was heavily inspired from [AnPur's PowerShellGet-Module](https://github.com/anpur/powershellget-module).\n","funding_links":[],"categories":["C# #"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmaitre314%2FPowerShellGet-Test-Binary-Module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmaitre314%2FPowerShellGet-Test-Binary-Module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmaitre314%2FPowerShellGet-Test-Binary-Module/lists"}