Skip to content

New-FileCatalog: Paths for catalog contains multiple files with same relative path #26702

@jdhitsolutions

Description

@jdhitsolutions

Prerequisites

Steps to reproduce

Create a simple folder structure with at least one file name duplicated in different folders. Save the paths to a variable.

PS C:\temp\data3> $files
C:\temp\data3\demo1.json
C:\temp\data3\demo2.json
C:\temp\data3\demo3.json
C:\temp\data3\docs\function\demo.ps1
C:\temp\data3\docs\function\demo2.ps1
C:\temp\data3\docs\x.txt
C:\temp\data3\files\demo1.json
C:\temp\data3\files\demo2.json
C:\temp\data3\foo\bar\that.txt
C:\temp\data3\foo\bar\this.txt
C:\temp\data3\foo\bar2\that.txt
C:\temp\data3\foo\bar2\this.txt
C:\temp\data3\localmodules2.json

In the folder run: new-fileCatalog -CatalogFilePath . -catalogVersion 2 -Path $files

Expected behavior

If I am reading the help correctly, this should create a catalog file for the listed files in `$files`. If I run `new-fileCatalog -CatalogFilePath . -catalogVersion 2` there are no errors, but I also end up with other catalog items like the hidden .git folder and files in my .gitexclude folder. I thought I could use the `-Path` parameter to create a very specific file catalog.

Actual behavior

Catalog is not created.

Error details

Exception             :
    Type       : System.InvalidOperationException
    TargetSite :
        Name          : ThrowTerminatingError
        DeclaringType : [System.Management.Automation.MshCommandRuntime]
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Message    : Paths for catalog contains multiple files with same relative path demo1.json.
    Source     : System.Management.Automation
    HResult    : -2146233079
    StackTrace :
   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
CategoryInfo          : InvalidOperation: (:) [New-FileCatalog], InvalidOperationException
FullyQualifiedErrorId : FoundDuplicateFilesRelativePath,Microsoft.PowerShell.Commands.NewFileCatalogCommand
InvocationInfo        :
    MyCommand        : New-FileCatalog
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 163
    Line             : new-fileCatalog -CatalogFilePath . -catalogVersion 2 -Path $files
    Statement        : new-fileCatalog -CatalogFilePath . -catalogVersion 2 -Path $files
    PositionMessage  : At line:1 char:1
                       + new-fileCatalog -CatalogFilePath . -catalogVersion 2 -Path $files
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : new-fileCatalog
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.4
PSEdition                      Core
GitCommitId                    7.5.4
OS                             Microsoft Windows 10.0.26200
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.WG-Cmdletsgeneral cmdlet issuesWG-NeedsReviewNeeds a review by the labeled Working Group

    Type

    No type

    Projects

    Status

    Queue

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions