Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

format.ps1xml files referencing built-in assemblies fail to load #4256

Copy link
Copy link
@DHowett-MSFT

Description

@DHowett-MSFT
Issue body actions

Steps to reproduce

This is a self-contained reproduction case with an inline format.ps1xml.

@"
<?xml version="1.0" encoding="utf-8" ?> 
<Configuration>
    <SelectionSets> <SelectionSet> <Name>ReproTypes</Name> <Types> <TypeName>ReproType</TypeName> </Types> </SelectionSet> </SelectionSets>
    <Controls>
        <Control>
            <Name>ReproGroupingFormat</Name>
                <CustomControl>
                    <CustomEntries>
                        <CustomEntry>
                            <CustomItem>
                                <Frame>
                                    <LeftIndent>4</LeftIndent>
                                    <CustomItem>
                                        <Text AssemblyName="System.Management.Automation" BaseName="FileSystemProviderStrings" ResourceId="DirectoryDisplayGrouping"/>
                                    </CustomItem> 
                                </Frame>
                            </CustomItem>
                        </CustomEntry>
                    </CustomEntries>
            </CustomControl>
        </Control>
    </Controls>
    
    <ViewDefinitions>
       <View>
            <Name>things</Name>
            <ViewSelectedBy> <SelectionSetName>ReproTypes</SelectionSetName> </ViewSelectedBy>
            <GroupBy>
                <PropertyName>Group</PropertyName> 
                <CustomControlName>ReproGroupingFormat</CustomControlName>  
            </GroupBy>
            <TableControl>
                <TableHeaders>
                   <TableColumnHeader> <Label>Whatever</Label> </TableColumnHeader>
                </TableHeaders>
                <TableRowEntries>
                    <TableRowEntry>
                        <TableColumnItems>
                            <TableColumnItem> <PropertyName>A</PropertyName> </TableColumnItem>
                        </TableColumnItems>
                    </TableRowEntry>
                </TableRowEntries>
            </TableControl>
        </View>
    </ViewDefinitions>
</Configuration>
"@ | Set-Content $Env:TEMP\repro.format.ps1xml

Class ReproType { [string]$Group; [string]$A; }
$v=([ReproType]@{Group="GroupOne"; A="1";}, [ReproType]@{Group="GroupOne"; A="2";}, [ReproType]@{Group="GroupTwo"; A="1";})
Update-FormatData $Env:TEMP\repro.format.ps1xml

$v | Format-Table

Expected behavior

The string Directory: would be loaded from assembly System.Management.Automation resource FileSystemProviderStrings.DirectoryDisplayGrouping

Directory:

Whatever
--------
1
2


Directory:

Whatever
--------
1

Actual behavior

Update-FormatData fails.

in file C:\Users\duhowett\AppData\Local\Temp\repro.format.ps1xml: The resource FileSystemProviderStrings in assembly C:\System.Management.Automation is not found.
At line:1 char:1
+ Update-FormatData $Env:TEMP\repro.format.ps1xml
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Update-FormatData], RuntimeException
    + FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.UpdateFormatDataCommand

The string C:\System.Management.Automation is very suspect.
The assembly is almost certainly loaded, as it provides many of the cmdlets in use here.

NOTE: On Linux, the missing assembly name is /System.Management.Automation

Environment data

Working

Name                           Value
----                           -----
PSVersion                      5.1.16245.1000
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16245.1000
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

(This also works on the version of PowerShell shipped inbox with rs2_release.)

Failing

Name                           Value
----                           -----
PSVersion                      6.0.0-beta
PSEdition                      Core
GitCommitId                    v6.0.0-beta.4
OS                             Microsoft Windows 10.0.16245
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Name                           Value
----                           -----
PSVersion                      6.0.0-beta
PSEdition                      Core
GitCommitId                    v6.0.0-beta.3
OS                             Linux 4.9.31-moby #1 SMP Sat Jun 24 06:29:23 UTC 2017
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.