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

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

Open
1 task done
aomader opened this issue May 15, 2024 · 5 comments
Labels
area-ui-rendering Includes: MVC Views/Pages, Razor Views/Pages feature-static-web-assets

Comments

@aomader
Copy link

aomader commented May 15, 2024

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
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label May 15, 2024
@amcasey
Copy link
Member

amcasey commented May 15, 2024

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.

@aomader
Copy link
Author

aomader commented May 15, 2024

@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).

@amcasey
Copy link
Member

amcasey commented May 15, 2024

@aomader Crazy. Thanks for confirming!

@mkArtakMSFT mkArtakMSFT added feature-static-web-assets area-ui-rendering Includes: MVC Views/Pages, Razor Views/Pages and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels May 17, 2024
@javiercn
Copy link
Member

@aomader thanks for reporting the issue.

It seems that the expression is missing quotes
$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\joint-controllership-agreement\bg-bg\38222\Информация за съвместната отговорност по отношение на субектите на данни съгласно чл. 26, параграф 2, точка 2 от ОРЗД.pdf))

This is likely not a problem in most situations until non ascii characters get introduced. I did a quick test and quoting the expression should fix the issue, we'll keep this issue around to produce a fix, which will have to go into the SDK.

$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\staticwebassets\joint-controllership-agreement\bg-bg\38222\Информация за съвместната отговорност по отношение на субектите на данни съгласно чл. 26, параграф 2, точка 2 от ОРЗД.pdf'))

@javiercn javiercn added this to the .NET 9 Planning milestone May 22, 2024
@javiercn
Copy link
Member

javiercn commented Jun 2, 2024

Addressed as part of dotnet/sdk#41244 since that code had to change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ui-rendering Includes: MVC Views/Pages, Razor Views/Pages feature-static-web-assets
Projects
None yet
Development

No branches or pull requests

5 participants
@aomader @javiercn @amcasey @mkArtakMSFT and others