MSB4186: [MSBuild]::MakeRelative fails for files with commas in filename in wwwroot (Static Web Assets)
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
### Description
Building an ASP.NET Core (Blazor) project fails with MSB4186 when a file inside `wwwroot`
has a comma in its filename. The static web assets pipeline internally calls
`[MSBuild]::MakeRelative($(MSBuildProjectDirectory), )` and MSBuild parses the comma
in the filename as an argument separator, resulting in 3 arguments instead of 2 —
hence "method not found".
### Steps to reproduce
1. Create an ASP.NET Core Blazor project
2. Place any file with a comma in its name under `wwwroot/files/`,
e.g. `wwwroot/files/Some file, with comma.xlsx`
3. Build the project
### Error
Error MSB4186: Invalid static method invocation syntax:
"[MSBuild]::MakeRelative($(MSBuildProjectDirectory),
D:...\wwwroot\files\Some file, with comma.xlsx)".
Method '[MSBuild]::MakeRelative' not found.
### Expected behavior
Files with commas in their names are valid on all platforms.
The SDK targets should quote or escape path arguments
when constructing `[MSBuild]::MakeRelative(...)` calls.
### Actual behavior
Build fails with MSB4186.
### Environment
- .NET SDK: 10.0.203
- OS: Windows 11
- Project type: Microsoft.NET.Sdk.Web (Blazor WebAssembly hosted)
### Workaround
Rename the file to remove the comma.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.