dotnet publish fails when publish directory has a semi-colon
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
Running `dotnet publish` fails when the publish directory is specified and has a semi-colon (either in a specified absolute path or computed from a specified relative path)
> Related to this, dotnet-publish fails with semicolon as well.
>
> ```sh
> $ dotnet new console -n 't;e;s;t'
> $ cd 't;e;s;t'
>
> $ dotnet publish -o dist
> MSBUILD : error MSB1006: Property is not valid.
> Switch: e
>
> For switch syntax, type "MSBuild -help"
>
> $ dotnet publish -p:PublishDir="$(pwd)/dist"
>
> The "HasTrailingSlash" function only accepts a scalar value, but its argument "$(ClickOncePublishDir)" evaluates to "/Users/adeel/projects/t;e;s;t/dist" which is not a scalar value. /Users/adeel/.dotnet9/sdk/9.0.100-rc.1.24414.26/Microsoft.Common.CurrentVersion.targets
> MSBUILD : error MSB1006: Property is not valid.
> Switch: e
>
> For switch syntax, type "MSBuild -help"
>
> # without publishdir or -o / --output, it works
> $ dotnet publish
> Restore complete (0,3s)
> You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
> t;e;s;t succeeded (0,3s) → bin/Release/net9.0/publish/
>
> Build succeeded in 0,7s
> ```
_Originally posted by @am11 in [#104402](https://github.com/dotnet/runtime/issues/104402#issuecomment-2309021636)_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.