ALL of my .net core dockerfiles are 99% the same except for this last line:
ENTRYPOINT ["dotnet", "<APP NAME HERE>.dll"]
seems pretty dumb of me because they could all be identical otherwise
Is there a way to change the dll name with the dotnet publish -c Release -o out
command? can I do that without having to modify csproj files or anything?
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.)