Azure / Azure/autorest.powershell

Not able to build PowerShell Module using TypeSpec

Open
#1,547 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
123
Forks
99
PR merge metrics
No merged PRs in 30d

Description

### Initially posted this issue in TypeSpec Community
https://github.com/microsoft/typespec/issues/10007

### 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: "*"
```

2. Run `tsp compile . `

3. `cd generated `
4. run `build-module.ps1`

Image

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the generated .psd1 shown in the report and the build-module.ps1 step that consumes it. Reproduce with the provided tspconfig.yaml and `tsp compile .`, then run build-module.ps1; done means the generated manifest has valid export entries without relying on the reported additional-psd1-data workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.