You can use this command to perform the build and rename the assembly:
dotnet msbuild -r -p:Configuration=Release;AssemblyName=foo
On Linux/macOS you will have to add quotes around the command, like this:
dotnet msbuild -r '-p:Configuration=Release;AssemblyName=foo'
However, there can be unintended side effects due to a global property being set. You should read this open issue from Sep 2019 as it speaks directly to your question regarding Docker and renaming the output: https://github.com/dotnet/msbuild/issues/4696
Also, I know you wanted to avoid editing the .csproj file, but in case you aren't aware, you can add the AssemblyName
property and set the output name in that manner.
Such as:
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>foo</AssemblyName>
</PropertyGroup>
This will create foo.dll
(and other files as well, e.g. .pdb
, .deps.json
, etc.)