Skip to content

Consuming a RCL with static web assets containing certain characters in the filenames leads to "invalid static method syntax" #55745

Closed
@aomader

Description

@aomader

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I am creating a simple RCL that comes with static web assets.

The project is very simple and defined like

<Project Sdk="Microsoft.NET.Sdk.Razor">
  <PropertyGroup>
    <StaticWebAssetBasePath>somepath</StaticWebAssetBasePath>
  </PropertyGroup>
</Project>

with some files in the wwwroot/ containing unicode characters.

Packaging it works fine (except for some long file name warnings), but that should not be a problem for now I assume.

When consuming the package in another project, I receive the following error (multiple of the same actually)

.../.nuget/packages/PKG/VER/build/Microsoft.AspNetCore.StaticWebAssets.props(1731,21): error MSB4186: Invalid static method invocation syntax: "[System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\joint-controllership-agreement\bg-bg\38222\Информация за съвместната отговорност по отношение на субектите на данни съгласно чл. 26, параграф 2, точка 2 от ОРЗД.pdf)". Method 'System.IO.Path.GetFullPath' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)). Check that all parameters are defined, are of the correct type, and are specified in the right order.

The mentioned .nuget/packages/PKG/VER/build/Microsoft.AspNetCore.StaticWebAssets.props contains the following entry at the echoed location:

...
    <StaticWebAsset Include="$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\joint-controllership-agreement\bg-bg\38222\Информация за съвместната отговорност по отношение на субектите на данни съгласно чл. 26, параграф 2, точка 2 от ОРЗД.pdf))">
      <SourceType>Package</SourceType>
      <SourceId>...</SourceId>
      <ContentRoot>$(MSBuildThisFileDirectory)..\staticwebassets\</ContentRoot>
      <BasePath>somepath</BasePath>
      <RelativePath>joint-controllership-agreement/bg-bg/38222/Информация за съвместната отговорност по отношение на субектите на данни съгласно чл. 26, параграф 2, точка 2 от ОРЗД.pdf</RelativePath>
      <AssetKind>All</AssetKind>
      <AssetMode>All</AssetMode>
      <AssetRole>Primary</AssetRole>
      <RelatedAsset></RelatedAsset>
      <AssetTraitName></AssetTraitName>
      <AssetTraitValue></AssetTraitValue>
      <CopyToOutputDirectory>Never</CopyToOutputDirectory>
      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
      <OriginalItemSpec>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\joint-controllership-agreement\bg-bg\38222\Информация за съвместната отговорност по отношение на субектите на данни съгласно чл. 26, параграф 2, точка 2 от ОРЗД.pdf))</OriginalItemSpec>
    </StaticWebAsset>
...

It is not clear to me what the issue is, since those files are generated automatically and I do not see anything obviously offending.

Expected Behavior

I would expect that the consuming project loads/builds just fine.

Steps To Reproduce

The following simple minimal example allows to reproduce the issue (at least on a Mac M1 with .NET 7).
example.zip

Extract example.zip and then running the steps

cd example/
dotnet pack -c Release dep-proj 
dotnet build con-proj

should result in the same error

MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  Restored /Users/MAO1LB/Downloads/example/con-proj/Con.csproj (in 131 ms).
/Users/MAO1LB/.nuget/packages/dep/1.0.0/build/Microsoft.AspNetCore.StaticWebAssets.props(3,21): error MSB4186: Invalid static method invocation syntax: "[System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\joint-controllership-agreement\bg-bg\38222\Информация за съвместната отговорност по отношение на субектите на данни съгласно чл. 26, параграф 2, точка 2 от ОРЗД.pdf)". Method 'System.IO.Path.GetFullPath' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)). Check that all parameters are defined, are of the correct type, and are specified in the right order. [/Users/MAO1LB/Downloads/example/con-proj/Con.csproj]

Build FAILED.

/Users/MAO1LB/.nuget/packages/dep/1.0.0/build/Microsoft.AspNetCore.StaticWebAssets.props(3,21): error MSB4186: Invalid static method invocation syntax: "[System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\joint-controllership-agreement\bg-bg\38222\Информация за съвместната отговорност по отношение на субектите на данни съгласно чл. 26, параграф 2, точка 2 от ОРЗД.pdf)". Method 'System.IO.Path.GetFullPath' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)). Check that all parameters are defined, are of the correct type, and are specified in the right order. [/Users/MAO1LB/Downloads/example/con-proj/Con.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.52

Exceptions (if any)

No response

.NET Version

8.0.101

Anything else?

$ dotnet --info
.NET SDK:
 Version:           8.0.101
 Commit:            6eceda187b
 Workload version:  8.0.100-manifests.69afb982

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  14.4
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /usr/local/share/dotnet/sdk/8.0.101/

.NET workloads installed:
 Workload version: 8.0.100-manifests.69afb982
There are no installed workloads to display.

Host:
  Version:      8.0.1
  Architecture: arm64
  Commit:       bf5e279d92

.NET SDKs installed:
  6.0.401 [/usr/local/share/dotnet/sdk]
  6.0.407 [/usr/local/share/dotnet/sdk]
  7.0.100 [/usr/local/share/dotnet/sdk]
  7.0.202 [/usr/local/share/dotnet/sdk]
  7.0.400 [/usr/local/share/dotnet/sdk]
  7.0.405 [/usr/local/share/dotnet/sdk]
  7.0.406 [/usr/local/share/dotnet/sdk]
  7.0.408 [/usr/local/share/dotnet/sdk]
  8.0.100 [/usr/local/share/dotnet/sdk]
  8.0.101 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.15 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.15 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.16 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.18 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.16 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.18 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  x64   [/usr/local/share/dotnet/x64]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions