Skip to content

Enable <PublishedSingleFileName> to be set in .csproj #51132

@jnm2

Description

@jnm2

I'd like to be able to control the published single file name independently from the assembly name. I can't set the assembly name to the desired published single file name because it would conflict with a library assembly name in the same project. However, the published single file name can be set to anything without causing a conflict, as evidenced by testing after renaming it to the desired file name after publishing.

It seems setting <PublishedSingleFileName>Xyz.exe</PublishedSingleFileName> in the .csproj is very close to working:

<PropertyGroup>
<PublishedSingleFileName>$(AssemblyName)$(_NativeExecutableExtension)</PublishedSingleFileName>
<PublishedSingleFilePath>$(PublishDir)$(PublishedSingleFileName)</PublishedSingleFilePath>
</PropertyGroup>

We just need to change one line to follow the standard MSBuild "provide default if not already set" pattern:

    <PropertyGroup>
      <PublishedSingleFileName Condition="'$(PublishedSingleFileName)' == ''">$(AssemblyName)$(_NativeExecutableExtension)</PublishedSingleFileName>
      <PublishedSingleFilePath>$(PublishDir)$(PublishedSingleFileName)</PublishedSingleFilePath>
    </PropertyGroup>

Alternatively, if it would be desirable to use a different csproj property which specifies only the name part without the .exe file extension, a new property could be introduced or PublishedSingleFileName could be refactored to not include the .exe part.

Happy to send a PR.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions