Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

NuGetApiKey is required for nuget based gallery service #463

Open
wants to merge 21 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
fd47e15
**DISABLE_SECRET_SCANNING**
alerickson Mar 13, 2019
c00f461
Merge development to master (#440)
alerickson Mar 14, 2019
8004c30
Merge remote-tracking branch 'origin/development'
alerickson Mar 15, 2019
0a2c684
Remove validation on NugetApiKey parameter
Apr 12, 2019
ff40856
Added scopeto Update-Module. Added localized error message (#471)
lwajswaj May 1, 2019
483dada
update tests (#469)
edyoung May 1, 2019
459695a
WIP: localdev publishing (#462)
Benny1007 May 2, 2019
8416d39
Changes to DSC resource PSModule (#450)
johlju May 7, 2019
432b55c
fix#191 update publish-module to allow exclude files. (#453)
Benny1007 May 7, 2019
18a9a98
Add SkipAutomaticTags Parameter to Publish-Module (#452)
awickham10 May 12, 2019
c3e0d7d
Add -Force to Get-ChildItem params (#476)
alerickson May 13, 2019
23797a9
Update module version and changelog (#477)
alerickson May 13, 2019
7de99ee
fix new-nugetpackage to cope with more output from child process (#479)
edyoung May 17, 2019
95eef98
Catch nuget error and diplay localized error instead
May 21, 2019
1aade96
Update version, packagemanagement dependency version, and changelog (…
edyoung May 21, 2019
0f667f2
Dependency update (#483)
alerickson May 21, 2019
bfc5284
Merge development to master (#440)
alerickson Mar 14, 2019
89ff9c5
Remove validation on NugetApiKey parameter
Apr 12, 2019
efe1de6
Catch nuget error and diplay localized error instead
May 21, 2019
ae1c8e0
rebase to match current development branch
May 22, 2019
22aba0c
fix silly rebase problem
May 22, 2019
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
97 changes: 97 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build and Import Module",
"command": "pwsh",
"type": "shell",
"windows": {
"command": "c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
},
"args": [
"-command",
"Import-Module ${workspaceFolder}\\tools\\build.psm1;",
"Install-DevelopmentModule",
],
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": false,
}
},
{
"label": "Install Dependencies",
"command": "pwsh",
"windows": {
"command": "c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
},
"args": [
"-command",
"Import-Module ${workspaceFolder}\\tools\\build.psm1;",
"Install-Dependencies"
],
"problemMatcher": [],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": false,
}
},
{
"label": "Remove Development Module",
"command": "pwsh",
"windows": {
"command": "c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
},
"args": [
"-command",
"Import-Module ${workspaceFolder}\\tools\\build.psm1;",
"Uninstall-DevelopmentModule"
],
"problemMatcher": [],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": false,
}
},
{
"label": "Run Full Test Suite",
"command": "pwsh",
"windows": {
"command": "c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
},
"args": [
"-command",
"Import-Module ${workspaceFolder}\\tools\\build.psm1;",
"Install-Dependencies;",
"Invoke-PowerShellGetTest"
],
"problemMatcher": [],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": false,
}
}
]
}
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
# Changelog

## 2.1.4

Bug Fix

- Fixed hang when publishing some modules (#478)

## 2.1.3

New Features

- Added -Scope parameter to Update-Module (Thanks @lwajswaj!) (#471)
- Added -Exclude parameter to Publish-Module (Thanks @Benny1007!) (#191)
- Added -SkipAutomticTags parameter to Publish-Module (Thanks @awickham10!) (#452)

Bug Fix

- Fixed issue with finding modules using macOS and .NET Core 3.0

## 2.1.2

New Feature

- Added support for registering repositories with special characters
- Added support for registering repositories with special characters (@Thanks jborean93!) (#442)

## 2.1.1

- Fix DSC resource folder structure

## 2.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ ConvertFrom-StringData -StringData @'
StartUnInstallModule = Begin invoking Remove-Item to remove the module '{0}' from the file system.
InstalledSuccess = Successfully installed the module '{0}'
UnInstalledSuccess = Successfully uninstalled the module '{0}'
VersionMismatch = The installed Module '{0}' has the version: '{1}'
RepositoryMismatch = The installed Module '{0}' is from '{1}' repository.
VersionMismatch = The installed module '{0}' has the version: '{1}'
RepositoryMismatch = The installed module '{0}' is from the '{1}' repository.
FoundModulePath = Found the module path: '{0}'.
MultipleModuleFound = Total: '{0}' modules found with the same name. Please use -RequiredVersion for filtering. Message: {1}
InstallationPolicyWarning = You are installing the module '{0}' from an untrusted repository' {1}'. Your current InstallationPolicy is '{2}'. If you trust the repository, set the policy to "Trusted".
InstallationPolicyFailed = Failed in the installation policy. Your current InstallationPolicy is '{0}' and the repository is '{1}'. If you trust the repository, set the policy to "Trusted".
InstallationPolicyWarning = The module '{0}' was installed from the untrusted repository' {1}'. The InstallationPolicy is set to '{2}' to override the repository installation policy. If you trust the repository, set the repository installation policy to 'Trusted', that will also remove this warning.
InstallationPolicyFailed = The current installation policy do not allow installation from this repository. Your current installation policy is '{0}' and the repository installation policy is '{1}'. If you trust the repository, either change the repository installation policy, or set the parameter InstallationPolicy to 'Trusted' to override the repository installation policy.
GetTargetResourceMessage = Getting the current state of the module '{0}'.
TestTargetResourceMessage = Determining if the module '{0}' is in the desired state.
'@
46 changes: 33 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,29 +106,49 @@ Import-Module src/PowerShellGet
```


Local Development
=================
### Visual Studio Code:-
1. Open VSCode choosing "Run as Administrator"
2. Select Terminal>Run Task>Install Dependencies
3. Select Terminal>Run Task>Build and Import Module

for subsequent changes you can just run 'Build and Import Module' or press <kbd>ctrl</kbd> + <kbd>shift</kbd> + <kbd>B</kbd>

### Standard PowerShell:-
1. Open an administrative PowerShell prompt
2. Run the following commands
```PowerShell
Import-Module "$ClonePath\tools\build.psm1"
Install-Dependencies
Install-DevelopmentModule
```

This will take the published module from ./dist and install it into the powershell module path under the current version of PowerShellGet apending 9999 to the version number.

An explicit or implicit (such as when the test suite is invoked) import of the PowerShell get module will ensure the module version under development gets loaded.

It is therefore easy to see with ```Get Module``` that the version under development is loaded, like this:-

![alt text](./imgs/readme-getmodule-1.png "")

To remove this module and revert to the production PowerShellGallery published version, simply remove the folder from the module path. (if running VSCode select Terminal>Run Task>Remove Development Module).

Running Tests
=============

### VSCode
You can run the test task Terminal>Run Task>Run Full Test Suite

### Non VSCode

Pester-based PowerShellGet Tests are located in `<branch>/PowerShellGet/Tests` folder.

Run following commands in PowerShell Console with Administrator privileges.

```powershell
Import-Module "$ClonePath\tools\build.psm1"

Install-Dependencies

# Option 1: Execute the following, replacing $ClonePath, when testing PowerShellGet module changes under $ClonePath.
# $env:PSModulePath = "$ClonePath\src;$env:PSModulePath"

# Option 2: Execute the following commands to run tests with the merged PSModule.psm1
<#
Update-ModuleManifestFunctions
Publish-ModuleArtifacts
Install-PublishedModule
#>

# Run tests
Invoke-PowerShellGetTest
```

Expand Down
2 changes: 1 addition & 1 deletion SignConfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
<file src="__INPATHROOT__\PowerShellGet\Modules\PowerShellGet.ResourceHelper\PowerShellGet.ResourceHelper.psm1" signType="AuthenticodeFormer" dest="__OUTPATHROOT__\Modules\PowerShellGet.ResourceHelper\PowerShellGet.ResourceHelper.psm1" />
<file src="__INPATHROOT__\PowerShellGet\Modules\PowerShellGet.LocalizationHelper\PowerShellGet.LocalizationHelper.psm1" signType="AuthenticodeFormer" dest="__OUTPATHROOT__\Modules\PowerShellGet.LocalizationHelper\PowerShellGet.LocalizationHelper.psm1" />
</job>
</SignConfigXML>
</SignConfigXML>
87 changes: 82 additions & 5 deletions Tests/PSGetPublishModule.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Describe PowerShell.PSGet.PublishModuleTests -Tags 'BVT','InnerLoop' {
#
# Expected Result: should be able to publish a module
#
It PublishModuleWithNameForSxSVersion {
It "PublishModuleWithNameForSxSVersion" {
$version = "2.0.0.0"
$semanticVersion = '2.0.0'
RemoveItem "$script:PublishModuleBase\*"
Expand Down Expand Up @@ -763,6 +763,83 @@ Describe PowerShell.PSGet.PublishModuleTests -Tags 'BVT','InnerLoop' {
} `
-Skip:$($PSVersionTable.PSVersion -lt '5.0.0')

# Purpose: Test Publish-Module cmdlet warns when tag length is greater than 4000
#
# Action: Create a module manifest with PrivateData\PSData hashtable, try to publish
#
# Expected Result: Publish operation should succeed and should have warned about tag length.
#
It PublishModuleFunctionsAsTagsWarnWithoutSkipAutomaticTags {
$version = "1.0.0"
$Description = "$script:PublishModuleName module"
$Tags = "PSGet","DSC"
$Author = "AuthorName"
$CompanyName = "CompanyName"
$CopyRight = "CopyRight"

$functionNames = 1..250 | Foreach-Object { "Get-TestFunction$($_)" }
$tempFunctions = 1..250 | Foreach-Object { "function Get-TestFunction$($_) { Get-Date }" + [Environment]::NewLine }
Set-Content (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psm1") -Value $tempFunctions

New-ModuleManifest -Path (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1") `
-ModuleVersion $version `
-Description "$script:PublishModuleName module" `
-NestedModules "$script:PublishModuleName.psm1" `
-Author $Author `
-CompanyName $CompanyName `
-Copyright $CopyRight `
-Tags $Tags `
-FunctionsToExport $functionNames

Publish-Module -Path $script:PublishModuleBase `
-NuGetApiKey $script:ApiKey `
-Repository "PSGallery" `
-WarningAction SilentlyContinue `
-WarningVariable wa

Assert ("$wa".Contains('4000 characters')) "Warning messages should include 'Tag list exceeded 4000 characters and may not be accepted by some Nuget feeds.'"
} `
-Skip:$($PSVersionTable.PSVersion -lt '5.0.0')

# Purpose: Test Publish-Module cmdlet excludes functions from tags when using SkipAutomaticTags parameter
#
# Action: Create a module manifest with PrivateData\PSData hashtable, try to publish with SkipAutomaticTags parameter
#
# Expected Result: Publish operation should succeed and should not have warned about tag length
#
It PublishModuleFunctionsAsTagsWithSkipAutomaticTags {
$version = "1.0.0"
$Description = "$script:PublishModuleName module"
$Tags = "PSGet","DSC"
$Author = "AuthorName"
$CompanyName = "CompanyName"
$CopyRight = "CopyRight"

$functionNames = 1..250 | Foreach-Object { "Get-TestFunction$($_)" }
$tempFunctions = 1..250 | Foreach-Object { "function Get-TestFunction$($_) { Get-Date }" + [Environment]::NewLine }
Set-Content (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psm1") -Value $tempFunctions

New-ModuleManifest -Path (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1") `
-ModuleVersion $version `
-Description "$script:PublishModuleName module" `
-NestedModules "$script:PublishModuleName.psm1" `
-Author $Author `
-CompanyName $CompanyName `
-Copyright $CopyRight `
-Tags $Tags `
-FunctionsToExport $functionNames

Publish-Module -Path $script:PublishModuleBase `
-NuGetApiKey $script:ApiKey `
-Repository "PSGallery" `
-SkipAutomaticTags `
-WarningAction SilentlyContinue `
-WarningVariable wa

Assert (-not "$wa".Contains('4000 characters')) "Warning messages should not include 'Tag list exceeded 4000 characters and may not be accepted by some Nuget feeds.'"
} `
-Skip:$($PSVersionTable.PSVersion -lt '5.0.0')

# Purpose: Test Publish-Module cmdlet gets the PSData properties from the module manifest file and also with Uri objects specified to the cmdlet
#
# Action: Create a module manifest with PrivateData\PSData hashtable, try to publish it with Uri objects to ProjectUri, IconUri and LicenseUri parameters
Expand Down Expand Up @@ -1176,7 +1253,7 @@ Describe PowerShell.PSGet.PublishModuleTests -Tags 'BVT','InnerLoop' {
finally {
Install-NuGetBinaries
}
} -Skip:$($PSEdition -eq 'Core')
} -Skip:$($PSEdition -eq 'Core' -or $env:APPVEYOR_TEST_PASS -eq 'True')

# Purpose: Validate that Publish-Module prompts to install NuGet.exe if NuGet.exe file is not found
#
Expand Down Expand Up @@ -1234,7 +1311,7 @@ Describe PowerShell.PSGet.PublishModuleTests -Tags 'BVT','InnerLoop' {
finally {
Install-NuGetBinaries
}
} -Skip:$($PSEdition -eq 'Core')
} -Skip:$($PSEdition -eq 'Core' -or $env:APPVEYOR_TEST_PASS -eq 'True')

# Purpose: Validate that Publish-Module prompts to upgrade NuGet.exe if local NuGet.exe file is less than minimum required version
#
Expand Down Expand Up @@ -1300,7 +1377,7 @@ Describe PowerShell.PSGet.PublishModuleTests -Tags 'BVT','InnerLoop' {
finally {
Install-NuGetBinaries
}
} -Skip:$($PSEdition -eq 'Core')
} -Skip:$($PSEdition -eq 'Core' -or $env:APPVEYOR_TEST_PASS -eq 'True')

# Purpose: Validate that Publish-Module prompts to install NuGet.exe if file not found
#
Expand Down Expand Up @@ -1357,7 +1434,7 @@ Describe PowerShell.PSGet.PublishModuleTests -Tags 'BVT','InnerLoop' {
finally {
Install-NuGetBinaries
}
} -Skip:$($PSEdition -eq 'Core')
} -Skip:$($PSEdition -eq 'Core' -or $env:APPVEYOR_TEST_PASS -eq 'True')
}

Describe PowerShell.PSGet.PublishModuleTests.P1 -Tags 'P1','OuterLoop' {
Expand Down
Loading