dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.

Home Page:https://asp.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

aomader opened this issue · comments

commented

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

Superficially, it doesn't look unicode-related. My guess would have been that multiple frameworks are involved (I notice the repro mentions 7.0 but the issue mentions 8.0), but @javiercn might know more about this area.

commented

@amcasey When I replace the Информация за съвместната отговорност по отношение на субектите на данни съгласно чл. 26, параграф 2, точка 2 от ОРЗД.pdf file in the provided example by another zero byte file having only ASCII characters in its name and having the same amount of characters (asdasdasdasdasdasdasdadasdasdasd asd asd asd asd ads ada dasd ads ads asd asd asd ads asd asd asd adas asd asd asd as.pdf) everything works just fine.

So I assume it is related to the characters contained in the filename, rather than the net7.0 target framework I specified (although I have a .NET 8 SDK installed as well).

@aomader Crazy. Thanks for confirming!