question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Publish-PSResource flatten folder and file structure

See original GitHub issue

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.

Steps to reproduce

Publish-PSResource -Credential $Cred -Repository $Repo -Path $Path $Path contains file tree but publish flatten it in nupkg

The problem triangled in #704 https://github.com/PowerShell/PowerShellGet/commit/270d57e7d86bb49735f35ee172b33050ad193e8b#diff-56bf43952db65da3734ae9fabbe720248ec3a4d18d87ee94ec8ce2b91bce4af1 line 354-359 vs 400-402

- var fileName = fileNamePath.Substring(_path.Length).Trim(_PathSeparators);
- var newFilePath = System.IO.Path.Combine(outputDir, fileName);
+ FileInfo fileInfo = new FileInfo(fileNamePath);
+ var newFilePath = System.IO.Path.Combine(outputDir, fileInfo.Name);

new one does not respect relative file path, only file name

Expected behavior

folder/file structure preserved
module.psd1
file1.ps1
public/
  file2.ps1
private/
  file3.ps1

Actual behavior

public/
private/
module.psd1
file1.ps1
file2.ps1
file3.ps1

Error details

No response

Environment data

Version    Name
-------    ----
3.0.17     PowerShellGet

Name                           Value
----                           -----
PSVersion                      7.2.6
PSEdition                      Core
GitCommitId                    7.2.6
OS                             Microsoft Windows 10.0.19043
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
MVKozlovcommented, Nov 1, 2022

@alerickson, I hope skipping hidden files/folders will be done too

1reaction
MVKozlovcommented, Oct 25, 2022

btw, v2 by default skip hidden files/folder such as .git , v3 is not

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flatten directory structure - powershell
The below function flattens the directory structure and copies files based on the last write date chosen. function mega-copy($srcdir,$destdir,$ ...
Read more >
How can I flatten out a folder in Windows 7, assuming all ...
The absolute easiest way is to enter the common root folder and do a search for all files (i.e. search for *). When...
Read more >
Command Line Fun: How to Flatten a Folder Hierarchy
Recently I was asked if I knew how to “flatten” a folder hierarchy. That is, copy all of the files contained within a...
Read more >
Flattening a nested directory
Basically, the way that works if that find goes through the entire directory tree and for each file ( -type f ) that...
Read more >
Flattening a Nested Directory in Linux
This structure consists of files in different levels of the nesting files, and flattening it using the tar command trick is not ideal....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found