Skip to content

[Bug]: Failed to Build PowerShell Module #10007

@jpurohit92

Description

@jpurohit92

Describe the bug

Hello Team,

I am able to generate the PowerShell module using TypeSpec but build-module.ps1 is failing to build powershell module.

The reason for this failure is incorrect .psd1 file.
in generated .psd1 file functiontoExport is not defined and because of that build fails.

below is sample .psd1 file.

@{
  GUID = 'eb86a394-c876-4c7d-b163-c3f93c11834f'
  RootModule = './Demo.psm1'
  ModuleVersion = '0.1.0'
  CompatiblePSEditions = 'Core', 'Desktop'
  Author = 'Microsoft Corporation'
  CompanyName = 'Microsoft Corporation'
  Copyright = 'Microsoft Corporation. All rights reserved.'
  Description = 'Microsoft Azure PowerShell: Demo cmdlets'
  PowerShellVersion = '5.1'
  DotNetFrameworkVersion = '4.7.2'
  RequiredAssemblies = './bin/Demo.private.dll'
  FormatsToProcess = './Demo.format.ps1xml'
  **FunctionsToExport =** 
  PrivateData = @{
    PSData = @{
      Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'Demo'
      LicenseUri = 'https://aka.ms/azps-license'
      ProjectUri = 'https://github.com/Azure/azure-powershell'
      ReleaseNotes = ''
    }
  }
}

Reproduction

  1. Create tspconfig.yaml
emit:
  - "/root/holodeck/node/node_modules/@azure-tools/typespec-powershell"
options:
  "/root/holodeck/node/node_modules/@azure-tools/typespec-powershell":
    source-file: "../api/src/main/resources/openapi.yml"
    service-name: "Holodeck"
    module-name: "Holodeck"
    is-data-plane: true
    # PERMANENT FIX: Force valid PowerShell syntax for exports
    additional-psd1-data:
      FunctionsToExport: "*"
      CmdletsToExport: "*"
  1. Run tsp compile .

  2. cd generated

  3. run build-module.ps1

Image

Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions