Skip to content

Generated .exe file is missing version info #4127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tfenster opened this issue Jan 4, 2020 · 12 comments
Closed

Generated .exe file is missing version info #4127

tfenster opened this issue Jan 4, 2020 · 12 comments

Comments

@tfenster
Copy link

tfenster commented Jan 4, 2020

If I publish my 3.1 console app using the following command, then the resulting .exe file does have the version info set:
dotnet publish "client.csproj" -c Release -r win-x64 --self-contained true /property:PublishTrimmed=true /property:PublishSingleFile=true /property:Version=0.1.0.0 -o /app/publish

If I do the exact same thing in a container using the mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-1809 image, the resulting .exe file does not have the version info set.

Steps to repro:

  1. Create a sample console project using dotnet new console -o client
  2. cd client
  3. Run dotnet publish "client.csproj" -c Release -r win-x64 --self-contained true /property:PublishTrimmed=true /property:PublishSingleFile=true /property:Version=0.1.0.0 -o /app/publish
  4. Check the properties of file c:\app\publish\client.exe. It should show something like this, as is correct in my opinion
    image
  5. Run docker run --rm -ti -v "<full-path>\client:c:\app" mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-1809 (of course replace <full-path> with your path) to get a session in the container
  6. cd app
  7. Run dotnet publish "client.csproj" -c Release -r win-x64 --self-contained true /property:PublishTrimmed=true /property:PublishSingleFile=true /property:Version=0.1.0.0 -o /app/publish, exactly as above
  8. Check the properties of file <full-path>\client\publish\. It should show something like this, in my opinion a bug
    image

dotnet --version shows 3.1.100 in both cases. Am I missing something?

@swaroop-sridhar
Copy link
Contributor

If you publish the app without /property:PublishTrimmed=true /property:PublishSingleFile=true does it change the behavior?

@tfenster
Copy link
Author

tfenster commented Jan 6, 2020

The generated .dll gets the metadata inside the container as well as directly on my machine. The .exe doesn't get the metadata even without those properties inside of the container

@tfenster
Copy link
Author

@swaroop-sridhar any feedback on this?

@swaroop-sridhar
Copy link
Contributor

@tfenster The SDK transfers information (ex: resources/icons) from the App DLL to the Host EXE using the HostModel DLL. Looks like some information (VersionInfo resource) is missing in this transfer.

CC: @wli3

@swaroop-sridhar
Copy link
Contributor

@wli3 This issue should probably be moved to Runtime repo (wrt HostWriter)
The HostModel simply copies resources between PE Files, not sure how the versioning info can be missed. This needs further investigation.

@wli3
Copy link

wli3 commented Jan 15, 2020

@swaroop-sridhar after Immo's permission change, no one can move issues anymore. So i will just use the old copy paste issue mover, is that ok?

@tfenster
Copy link
Author

@wli3 @swaroop-sridhar would that be here https://github.com/dotnet/runtime/issues? I am happy to create a copy there, if that helps

@swaroop-sridhar
Copy link
Contributor

@tfenster, yes that's the right repo. Let's keep the issue here for now, until we figure out how to transfer the issue. Thanks.

@bravecobra
Copy link

I seem to have the exact same issue, and it is reproducible.

@tfenster
Copy link
Author

@bravecobra absolutely 100% and easily reproducible. Unfortunately there hasn't been any feedback apart from discussing whether or not this is the right repo and how to maybe get it somewhere else

@swaroop-sridhar @wli3 any progress on this?

@bravecobra
Copy link

I can confirm that the version information is compiled into the assembly. With reflection you get the correct version from the assembly itself, however that information isn't copied to the PE header when building on Linux/container targeting win-x64.

@swaroop-sridhar
Copy link
Contributor

swaroop-sridhar commented Feb 12, 2020

@tfenster @bravecobra I think I understand the problem here.

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.

There is an issue dotnet/runtime#3828 filed for implementing ResourceUpdater in managed code. Once this happens, the version information will be transfered regardless of the host machine configuration.

@wli3 I think we can resolve this issue as a dup of dotnet/runtime#3828.
Isn't it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants