We are attempting to build a .NET core 3.1 app within a container, using dotnet publish
, dotnet build
or dotnet msbuild
commands, with different parameters. Which succeeds, but the problem is that EXE output never shows any file Details (Copyright, File version, etc. are empty), while DLLs do contain specified information. We've tried several different containers, as well as researching online and trying different command parameters, for versioning (there are a few). Also, running identical dotnet publish command on my Windows 10 machine directly, works as expected, no issues.
I've also attempted separating dotnet build
and dotnet publish
(--no-build
) commands and copying a code signed EXE in-between, in case there is a trust issue, but nothing worked.
Dockerfile content (also used dotnet publish
instead of msbuild
):
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine3.11
ARG Version="5.6.7"
WORKDIR /build
COPY ./src $WORKDIR
RUN dotnet restore
RUN echo $Version
RUN dotnet msbuild abc.csproj /t:Build /p:PublishSingleFile=True /p:SelfContained=True /p:PublishProtocol=FileSystem /p:Configuration=Release /p:Platform=x64 /p:TargetFrameworks=netcoreapp3.1 /p:PublishDir=publish /p:RuntimeIdentifier=win-x64 /p:PublishReadyToRun=False /p:PublishTrimmed=False /p:VersionNumber=$Version /p:VersionPrefix=$Version /p:Version=$Version /p:AssemblyVersion=$Version /p:AssemblyVersionAttribute=$Version /p:FileVersion=$Version /p:AssemblyFileVersionAttribute=$Version
Steps to reproduce:
This issue is described here: https://github.com/dotnet/sdk/issues/4127. From that link:
The PE resources are transferred from App.dll to the host App.exe only when building on Windows -- because the resource handling code currently uses native Win32 API. So, when the app is published from Linux or nanoserver, the resources are not transfered.
That issue was closed, pointing to planned cross-platform work to re-write the way these resources are written (https://github.com/dotnet/runtime/issues/3828). That work has been pushed off to the dotnet 6.0.0 milestone, so unfortunately for now the only way to get the .exe to include these assembly info resources is to run the dotnet publish
command directly on a Windows host.