Skip to content

Commit 83c98ee

Browse files
authored
Freshness update - part2 (#12567)
1 parent bd7af5d commit 83c98ee

12 files changed

+289
-303
lines changed

reference/docs-conceptual/dev-cross-plat/Writing-Portable-Modules.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
description: This article explains how to create modules new modules or update existing modules so that they work across the platforms supported by PowerShell.
3-
ms.date: 11/16/2022
3+
ms.date: 12/08/2025
44
title: Writing Portable Modules
55
---
66

77
# Portable Modules
88

9-
Windows PowerShell is written for [.NET Framework][06] while PowerShell Core is written for
10-
[.NET Core][03]. Portable modules are modules that work in both Windows PowerShell and PowerShell
9+
Windows PowerShell is written for [.NET Framework][03] while PowerShell Core is written for
10+
[.NET Core][04]. Portable modules are modules that work in both Windows PowerShell and PowerShell
1111
Core. While .NET Framework and .NET Core are highly compatible, there are differences in the
1212
available APIs between the two. There are also differences in the APIs available in Windows
1313
PowerShell and PowerShell Core. Modules intended to be used in both environments need to be aware of
@@ -17,12 +17,12 @@ these differences.
1717

1818
### Porting a PSSnapIn
1919

20-
PowerShell [SnapIns][09] aren't supported in PowerShell Core. However, it's trivial to convert a
20+
PowerShell [SnapIns][07] aren't supported in PowerShell Core. However, it's trivial to convert a
2121
PSSnapIn to a PowerShell module. Typically, the PSSnapIn registration code is in a single source
22-
file of a class that derives from [PSSnapIn][01]. Remove this source file from the build; it's no
22+
file of a class that derives from [PSSnapIn][14]. Remove this source file from the build; it's no
2323
longer needed.
2424

25-
Use [New-ModuleManifest][08] to create a new module manifest that replaces the need for the PSSnapIn
25+
Use [New-ModuleManifest][13] to create a new module manifest that replaces the need for the PSSnapIn
2626
registration code. Some values from the **PSSnapIn** (such as **Description**) can be reused within
2727
the module manifest.
2828

@@ -32,14 +32,14 @@ The **RootModule** property in the module manifest should be set to the name of
3232
### The .NET Portability Analyzer (aka APIPort)
3333

3434
To port modules written for Windows PowerShell to work with PowerShell Core, start with the
35-
[.NET Portability Analyzer][11]. Run this tool against your compiled assembly to determine if the
35+
[.NET Portability Analyzer][08]. Run this tool against your compiled assembly to determine if the
3636
.NET APIs used in the module are compatible with .NET Framework, .NET Core, and other .NET runtimes.
37-
The tool suggests alternate APIs if they exist. Otherwise, you may need to add [runtime checks][02]
37+
The tool suggests alternate APIs if they exist. Otherwise, you may need to add [runtime checks][15]
3838
and restrict capabilities not available in specific runtimes.
3939

4040
## Creating a new module
4141

42-
If creating a new module, the recommendation is to use the [.NET CLI][05].
42+
If creating a new module, the recommendation is to use the [.NET CLI][02].
4343

4444
### Installing the PowerShell Standard module template
4545

@@ -143,15 +143,15 @@ FavoriteNumber FavoritePet
143143
### Debugging the module
144144

145145
For a guide on setting up Visual Studio Code to debug the module, see
146-
[Using Visual Studio Code for debugging compiled cmdlets][15].
146+
[Using Visual Studio Code for debugging compiled cmdlets][12].
147147

148148
## Supporting technologies
149149

150150
The following sections describe in detail some of the technologies used by this template.
151151

152152
### .NET Standard Library
153153

154-
[.NET Standard][07] is a formal specification of .NET APIs that are available in all .NET
154+
[.NET Standard][05] is a formal specification of .NET APIs that are available in all .NET
155155
implementations. Managed code targeting .NET Standard works with the .NET Framework and .NET Core
156156
versions that are compatible with that version of the .NET Standard.
157157

@@ -173,10 +173,10 @@ PowerShell Core 6 without recompilation.
173173

174174
### PowerShell Standard Library
175175

176-
The [PowerShell Standard][12] library is a formal specification of PowerShell APIs available in all
176+
The [PowerShell Standard][09] library is a formal specification of PowerShell APIs available in all
177177
PowerShell versions greater than or equal to the version of that standard.
178178

179-
For example, [PowerShell Standard 5.1][13] is compatible with both Windows PowerShell 5.1 and
179+
For example, [PowerShell Standard 5.1][10] is compatible with both Windows PowerShell 5.1 and
180180
PowerShell Core 6.0 or newer.
181181

182182
We recommend you compile your module using PowerShell Standard Library. The library ensures the APIs
@@ -189,7 +189,7 @@ will always be compatible with future versions of PowerShell.
189189
#### Indicating Compatibility With Windows PowerShell and PowerShell Core
190190

191191
After validating that your module works with both Windows PowerShell and PowerShell Core, the module
192-
manifest should explicitly indicate compatibility by using the [CompatiblePSEditions][10] property.
192+
manifest should explicitly indicate compatibility by using the [CompatiblePSEditions][06] property.
193193
A value of `Desktop` means that the module is compatible with Windows PowerShell, while a value of
194194
`Core` means that the module is compatible with PowerShell Core. Including both `Desktop` and `Core`
195195
means that the module is compatible with both Windows PowerShell and PowerShell Core.
@@ -203,7 +203,7 @@ means that the module is compatible with both Windows PowerShell and PowerShell
203203

204204
First, validate that your module works on Linux and macOS. Next, indicate compatibility with those
205205
operating systems in the module manifest. This makes it easier for users to find your module for
206-
their operating system when published to the [PowerShell Gallery][14].
206+
their operating system when published to the [PowerShell Gallery][11].
207207

208208
Within the module manifest, the `PrivateData` property has a `PSData` sub-property. The optional
209209
`Tags` property of `PSData` takes an array of values that show up in PowerShell Gallery. The
@@ -272,7 +272,7 @@ Prior to PowerShell 7, one would have to have custom code to load the appropriat
272272
the managed library can find it correctly.
273273

274274
With PowerShell 7, native binaries to load are searched in sub-folders within the managed library's
275-
location following a subset of the [.NET RID Catalog][04] notation.
275+
location following a subset of the [.NET RID Catalog][01] notation.
276276

277277
```
278278
managed.dll folder
@@ -306,18 +306,18 @@ managed.dll folder
306306
```
307307

308308
<!-- link references -->
309-
[01]: /dotnet/api/system.management.automation.pssnapin
310-
[02]: /dotnet/api/system.runtime.interopservices.runtimeinformation.frameworkdescription#System_Runtime_InteropServices_RuntimeInformation_FrameworkDescription
311-
[03]: /dotnet/core/
312-
[04]: /dotnet/core/rid-catalog
313-
[05]: /dotnet/core/tools/?tabs=netcore2x
314-
[06]: /dotnet/framework/
315-
[07]: /dotnet/standard/net-standard
316-
[08]: /powershell/module/microsoft.powershell.core/new-modulemanifest
317-
[09]: /powershell/scripting/developer/cmdlet/modules-and-snap-ins
318-
[10]: /powershell/gallery/concepts/module-psedition-support
319-
[11]: https://github.com/Microsoft/dotnet-apiport
320-
[12]: https://github.com/PowerShell/PowerShellStandard
321-
[13]: https://www.nuget.org/packages/PowerShellStandard.Library/5.1.0
322-
[14]: https://www.powershellgallery.com
323-
[15]: vscode/using-vscode-for-debugging-compiled-cmdlets.md
309+
[01]: /dotnet/core/rid-catalog
310+
[02]: /dotnet/core/tools/
311+
[03]: /dotnet/framework/
312+
[04]: /dotnet/fundamentals/
313+
[05]: /dotnet/standard/net-standard
314+
[06]: /powershell/gallery/concepts/module-psedition-support
315+
[07]: /powershell/scripting/developer/cmdlet/modules-and-snap-ins
316+
[08]: https://github.com/Microsoft/dotnet-apiport
317+
[09]: https://github.com/PowerShell/PowerShellStandard
318+
[10]: https://www.nuget.org/packages/PowerShellStandard.Library/5.1.0
319+
[11]: https://www.powershellgallery.com
320+
[12]: vscode/using-vscode-for-debugging-compiled-cmdlets.md
321+
[13]: xref:Microsoft.PowerShell.Core.New-ModuleManifest
322+
[14]: xref:System.Management.Automation.PSSnapIn
323+
[15]: xref:System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription%2A

0 commit comments

Comments
 (0)