Skip to content

error MSB4186: Invalid static method invocation syntax: #31770

@Bartmax

Description

@Bartmax

Describe the bug

When publishing I get this error:

error MSB4186: Invalid static method invocation syntax: "[MSBuild]::MakeRelative('$(MSBuildProjectDirectory)','$([MSBuild]::NormalizePath('wwwroot\/\videos\lkr_app-preview_1920x1080%2816,9%29_1.mp4'))')".

I can confirm the issue is because the filename is called: lkr_app-preview_1920x1080(16,9)_1.mp4 and the issue is having a comma , on it's name.

To Reproduce

I was able to reproduce by only including a file with a , on it's name: FileWithComma,InTheName.txt
Here's a repo with minimal repro commit: Bartmax/PublishBug@d3a9b96

Exceptions (if any)

C:\Program Files\dotnet\sdk\6.0.100-preview.3.21202.5\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets(540,9): error MSB4186: Invalid static method invocation syntax: "[MSBuild]::MakeRelative('$(MSBuildProjectDirectory)','$([MSBuild]::NormalizePath('wwwroot\/\FileWithComma,InTheName.txt'))')". Method '[MSBuild]::MakeRelative' 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. [C:\Development\Experiments\PublishBug\Server\PublishBug.Server.csproj]

Bonus

Visual studio new Git user experience is not able to add the file alone, must be done manually using git.

dotnet --info ### Further technical details .NET SDK (reflecting any global.json): Version: 6.0.100-preview.3.21202.5 Commit: aee38a6dd4

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100-preview.3.21202.5\

Host (useful for support):
Version: 6.0.0-preview.3.21201.4
Commit: 236cb21e3c

.NET SDKs installed:
5.0.100-rc.1.20452.10 [C:\Program Files\dotnet\sdk]
5.0.100-rc.2.20479.15 [C:\Program Files\dotnet\sdk]
5.0.103 [C:\Program Files\dotnet\sdk]
5.0.200-preview.20601.7 [C:\Program Files\dotnet\sdk]
5.0.200-preview.21077.7 [C:\Program Files\dotnet\sdk]
5.0.201 [C:\Program Files\dotnet\sdk]
6.0.100-preview.3.21202.5 [C:\Program Files\dotnet\sdk]

Error happens with NET 5 too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DoneThis issue has been fixedarea-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.feature-static-web-assets

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions