Skip to content

dotnet publish fails when publish directory has a semi-colon #49671

Open
@elinor-fung

Description

@elinor-fung

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.

$ 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions