Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion src/code/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@ private static bool TryReadPSDataFile(
public static bool ValidateModuleManifest(string moduleManifestPath, out string errorMsg)
{
errorMsg = string.Empty;
using (System.Management.Automation.PowerShell pwsh = System.Management.Automation.PowerShell.Create())
using (System.Management.Automation.PowerShell pwsh = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace))
{
// use PowerShell cmdlet Test-ModuleManifest
// TODO: Test-ModuleManifest will throw an error if RequiredModules specifies a module that does not exist
Expand Down
15 changes: 15 additions & 0 deletions test/PublishPSResourceTests/PublishPSResource.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ Describe "Test Publish-PSResource" -tags 'CI' {
}
}

It "Publish a module with valid Author field without -SkipModuleManifestValidate" {
# This test verifies that the fix for runspace deserialization issue works correctly.
# Previously, PSModuleInfo.Author would return empty string when called via PowerShell.Create(),
# causing false positive "No author was provided" errors.
$version = "1.0.0"
$author = "TestAuthor"
New-ModuleManifest -Path (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1") -ModuleVersion $version -Description "$script:PublishModuleName module" -Author $author

# This should succeed without needing -SkipModuleManifestValidate
Publish-PSResource -Path $script:PublishModuleBase -Repository $testRepository2

$expectedPath = Join-Path -Path $script:repositoryPath2 -ChildPath "$script:PublishModuleName.$version.nupkg"
(Get-ChildItem $script:repositoryPath2).FullName | Should -Be $expectedPath
}

It "Publish a module with -Path to the highest priority repo" {
$version = "1.0.0"
New-ModuleManifest -Path (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1") -ModuleVersion $version -Description "$script:PublishModuleName module"
Expand Down
Loading