Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robocopy mode of Copy-File fails to copy files or folders when path begins with .\ or ..\ #938

Closed
DanGough opened this issue Apr 5, 2024 · 2 comments
Assignees
Labels

Comments

@DanGough
Copy link
Contributor

DanGough commented Apr 5, 2024

Describe the bug
The Robocopy implementation in Copy-File does not like paths beginning with .\ or ..\
Having \..\ in middle of a folder path does work.

To Reproduce

These succeed but fail when -UseRobocopy is set to $true:

Copy-File -Path .\toolkit -Destination $env:temp -Recurse -UseRobocopy $false
Copy-File -Path .\TODO.txt -Destination $env:temp -Recurse -UseRobocopy $false
Copy-File -Path ..\PSAppDeployToolkit\TODO.txt -Destination $env:temp -Recurse -UseRobocopy $false
Copy-File -Path ..\PSAppDeployToolkit -Destination $env:temp -Recurse -UseRobocopy $false

Toolkit Version:
3.10.0 plus latest Copy-File fixes commited to Develop as of Apr 3, 2024.

@DanGough DanGough added the bug label Apr 5, 2024
@DanGough DanGough self-assigned this Apr 5, 2024
DanGough added a commit that referenced this issue Apr 5, 2024
@DanGough DanGough mentioned this issue Apr 5, 2024
4 tasks
@freedbygrace
Copy link

freedbygrace commented Apr 5, 2024

The following will fix seemingly fixes the issue.

$ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("..\Testing")

Resolve path does the same thing, but throws an unnessary error if the path does not exist! Why, the world may never know.

In any case, the above worked in my use case, however, not sure if it works going back to Powershell 2.0, Powershell 7 etc.

Reference Link: https://stackoverflow.com/questions/3038337/powershell-resolve-path-that-might-not-exist

@DanGough
Copy link
Contributor Author

DanGough commented Apr 5, 2024

Thanks for the tip!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants