Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
---
external help file: Microsoft.PowerShell.PSResourceGet.dll-Help.xml
Module Name: Microsoft.PowerShell.PSResourceGet
ms.custom: 1.1.0-preview.2
ms.date: 09/13/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.psresourceget/compress-psresource?view=powershellget-3.x&WT.mc_id=ps-gethelp
schema: 2.0.0
---

# Compress-PSResource

## SYNOPSIS

Compresses a specified folder containing module or script resources into a `.nupkg` file.

## SYNTAX

```
Compress-PSResource [-Path] <String> [-DestinationPath] <String> [-PassThru] [-WhatIf] [-Confirm]
[<CommonsParameters>]
```

## DESCRIPTION

This cmdlet compresses a specified folder containing module or script resources into a `.nupkg`
file. isolates the pack feature in the `Publish-PSResource` cmdlet. This allows you to sign the
`.nupkg` file before publishing it to a repository. You can publish the final `.nupkg` file using
the **NupkgPath** parameter of `Publish-PSResource`.

This command was added in v1.1.0-preview.2 of **Microsoft.PowerShell.PSResourceGet**.

## EXAMPLES

### Example 1

This example compresses the module **TestModule** and saves te nupkg to the DestinationPath.

```powershell
Compress-PSResource -Path C:\TestModule -DestinationPath C:\NupkgDestination
```

## PARAMETERS

### -DestinationPath

Path to save the compressed resource.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -PassThru

Pass the full path of the nupkg through the pipeline.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Path

Path to the resource to be compressed.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -SkipModuleManifestValidate

Skips validating the module manifest before publishing.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Confirm

Prompts you for confirmation before running the cmdlet.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -WhatIf

Shows what would happen if the cmdlet runs. The cmdlet isn't run.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

### None

## OUTPUTS

### System.String

By default, this command doesn't write any output to the pipeline. When you use the **PassThru**
parameter, it returns full path of the `.nupkg` that was created.

## NOTES

The module defines `cmres` as an alias for `Compress-PSResource`.

This cmdlet allows for publishing nuspec dependencies into ACR.

## RELATED LINKS

[Publish-PSResource](Publish-PSResource.md)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
external help file: Microsoft.PowerShell.PSResourceGet.dll-Help.xml
Module Name: Microsoft.PowerShell.PSResourceGet
ms.custom: 1.0.5
ms.date: 05/17/2024
ms.custom: 1.1.0-preview.2
ms.date: 09/13/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.psresourceget/publish-psresource?view=powershellget-3.x&WT.mc_id=ps-gethelp
schema: 2.0.0
---
Expand All @@ -15,19 +15,29 @@ Publishes a specified module from the local computer to PSResource repository.

## SYNTAX

### PathParameterSet

```
Publish-PSResource [-ApiKey <String>] [-Repository <String>] [-Path] <String>
[-DestinationPath <String>] [-Credential <PSCredential>] [-SkipDependenciesCheck]
[-SkipModuleManifestValidate] [-Proxy <Uri>] [-ProxyCredential <PSCredential>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-SkipModuleManifestValidate] [-Proxy <Uri>] [-ProxyCredential <PSCredential>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### NupkgPathParameterSet

```
Publish-PSResource [-ApiKey <String>] [-Repository <String>] [-DestinationPath <String>]
[-Credential <PSCredential>] [-SkipDependenciesCheck] [-SkipModuleManifestValidate] [-Proxy <Uri>]
[-ProxyCredential <PSCredential>] -NupkgPath <String> [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION

This cmdlet combines the functions of the `Publish-Module` and `Publish-Script` cmdlets from
**PowerShellGet** v2. `Publish-PSResource` publishes a resource from the local computer to an online
Nuget-based repository. You can specify the resource by the resource's name or by the path
containing the module or script resource.
NuGet-based repository. You can specify the resource by a path containing the module or script
resource files or by pointing a prepackaged `.nupkg` file.

## EXAMPLES

Expand All @@ -48,6 +58,14 @@ that's generated by the PowerShell Gallery for a user account.
Publish-PSResource -Path c:\TestModule -Repository PSGallery -APIKey '1234567'
```

### Example 3

This example publishes the module Nupkg **TestModule.nupkg** to a repositroy named TestRepository.

```powershell
Publish-PSResource -NupkgPath c:\TestModule.nupkg -Repository TestRepository
```

## PARAMETERS

### -ApiKey
Expand Down Expand Up @@ -100,10 +118,31 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -NupkgPath

Path to the `.nupkg` file to be published. The `.nupkg` file could have been created by a previous
run of `Publish-PSResource` with the **DestinationPath** parameter. Or, you can create the `.nupkg`
file using the `Compress-PSResource` command.

This parameter was added in v1.1.0-preview.2 of **Microsoft.PowerShell.PSResourceGet**.

```yaml
Type: System.String
Parameter Sets: NupkgPathParameterSet
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Path

The path to the module or script file or the path to a folder containing the module or script file
to be published.
to be published. The cmdlet packages all files in the folder into a `.nupkg` file before publishing
to the repository.

```yaml
Type: System.String
Expand Down Expand Up @@ -252,3 +291,5 @@ Fileshare-based repository have no metadata about the resources. Therefore, ther
for dependencies.

## RELATED LINKS

[Compress-PSResource](Compress-PSResource.md)