Skip to content
Draft
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
3 changes: 2 additions & 1 deletion src/code/PublishHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
private string pathToModuleDirToPublish = string.Empty;
private string pathToNupkgToPublish = string.Empty;
private ResourceType resourceType = ResourceType.None;
private NetworkCredential _networkCredential;

Check warning on line 53 in src/code/PublishHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, manual)

Field 'PublishHelper._networkCredential' is never assigned to, and will always have its default value null
string userAgentString = UserAgentInfo.UserAgentString();
private bool _isNupkgPathSpecified = false;
private Hashtable dependencies;
Expand Down Expand Up @@ -605,7 +605,8 @@
Path = nuspecFile,
Exclude = System.Array.Empty<string>(),
Symbols = false,
Logger = NullLogger.Instance
Logger = NullLogger.Instance,
NoDefaultExcludes = true
},
MSBuildProjectFactory.ProjectCreator,
builder);
Expand Down
30 changes: 30 additions & 0 deletions test/PublishPSResourceTests/CompressPSResource.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,36 @@ Describe "Test Compress-PSResource" -tags 'CI' {
}
}

It "Compress-PSResource includes .gitkeep files (empty and non-empty)" {
$version = "1.0.0"
New-ModuleManifest -Path (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1") -ModuleVersion $version -Description "$script:PublishModuleName module"

# Create 'hidden' directory with .gitkeep files
$hiddenDir = Join-Path -Path $script:PublishModuleBase -ChildPath "hidden"
New-Item -Path $hiddenDir -ItemType Directory -Force

# Create empty .gitkeep file in 'hidden' directory
$hiddenGitkeep = Join-Path -Path $hiddenDir -ChildPath ".gitkeep"
New-Item -Path $hiddenGitkeep -ItemType File -Force

Compress-PSResource -Path $script:PublishModuleBase -DestinationPath $script:repositoryPath

# Extract and verify files are included
$nupkgPath = Join-Path -Path $script:repositoryPath -ChildPath "$script:PublishModuleName.$version.nupkg"
$zipPath = Join-Path -Path $script:repositoryPath -ChildPath "$script:PublishModuleName.$version.zip"
Rename-Item -Path $nupkgPath -NewName $zipPath
$unzippedPath = Join-Path -Path $TestDrive -ChildPath "$script:PublishModuleName-gitkeep-test"
New-Item $unzippedPath -ItemType directory -Force
Expand-Archive -Path $zipPath -DestinationPath $unzippedPath

# Verify both .gitkeep files exist
$extractedHiddenkeep = Join-Path -Path $unzippedPath -ChildPath "hidden" | Join-Path -ChildPath ".gitkeep"

Test-Path -Path $extractedHiddenkeep | Should -Be $True

$null = Remove-Item $unzippedPath -Force -Recurse
}

<# Test for Signing the nupkg. Signing doesn't work
It "Compressed Module is able to be signed with a certificate" {
$version = "1.0.0"
Expand Down