Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Add AppHost Binary transformation Utilities to HostModel #6831

Merged
merged 3 commits into from
Jun 18, 2019

Conversation

swaroop-sridhar
Copy link

The code that transforms AppHost binary in order to update the
path to the App.dll binary lives in multiple repositories
(SDK, CLI and partly in core-setup tests).

This change adds the code to HostModel library, so that other
copies can be removed.

This also facilitates implementing a similar mechanism to
locate the offset of the bundle header within the binary
(so that the bundle headers are not required to live at the end
of the file).

  • Please add a description for changes you are making.
  • If there is an issue related to this PR, please add a reference to it.
  • If this PR should not run tests please add say skip_ci_please in this description replacing the underscores with spaces.

The code that transforms AppHost binary in order to update the
path to the App.dll binary lives in multiple repositories
(SDK, CLI and partly in core-setup tests).

This change adds the code to HostModel library, so that other
copies can be removed.

This also facilitates implementing a similar mechanism to
locate the offset of the bundle header within the binary
(so that the bundle headers are not required to live at the end
of the file).
// Copy resources from managed dll to the apphost
new ResourceUpdater(appHostDestinationFilePath)
.AddResourcesFromPEImage(intermediateAssembly)
.Update();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it a throw instead of logging

string appHostDestinationFilePath,
string appBinaryFilePath,
bool windowsGraphicalUserInterface = false,
string intermediateAssembly = null)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a better name than intermediateAssembly

{
if (!appHostIsPEImage)
{
throw new BinaryUpdateException($"Unable to use '{appHostSourceFilePath}' as application host executable because it's not a Windows executable for the CUI (Console) subsystem");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw them in distinguished error types


private static void ThrowExceptionForInvalidUpdate()
{
throw new InvalidOperationException("Update handle is invalid. This instance may not be used for further updates");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this type of developer exception is ok to be just in english

@jkoritzinsky
Copy link
Member

jkoritzinsky commented Jun 17, 2019

Do we want to use the new non-OS-bound PE resource APIs that @davidwrighton did for xplat IBCMerge or do we want to wait on that until a future PR/post-3.0?

1) Throw different exceptions for each error (instead of passing the message)
2) Add the GetGUIBit method.
@swaroop-sridhar swaroop-sridhar changed the title WIP: Add AppHost Binary transformatuin Utilities to HostModel Add AppHost Binary transformation Utilities to HostModel Jun 18, 2019
@swaroop-sridhar
Copy link
Author

@wli3, thanks for the comments, I've made the changes now.

/// </summary>
public class AppNameTooLongException : AppHostUpdateException
{
public string LongName;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe just expose {get;}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it in this commit: ff295f5

@wli3
Copy link

wli3 commented Jun 18, 2019

👍

@swaroop-sridhar
Copy link
Author

Do we want to use the new non-OS-bound PE resource APIs that @davidwrighton did for xplat IBCMerge or do we want to wait on that until a future PR/post-3.0?

I think we should bring the code over as-is. If the resource-updater APIs can be made public, then we can change it.

@swaroop-sridhar
Copy link
Author

@dotnet-bot test dotnet.core-setup (Build_OSX release)
@dotnet-bot test dotnet.core-setup (Build_Linux_x64_glibc debug)

@nguerrera
Copy link

Do we want to use the new non-OS-bound PE resource APIs

Ooh. Yes, please!

I think we should bring the code over as-is. If the resource-updater APIs can be made public, then we can change it.

OK.

@davidwrighton
Copy link
Member

Yes, I would continue this PR without pulling in the non OS bound PE resource apis. The work that I did around the non OS bound PE resource apis should be just about drop in compatible with the OS api surface, so it should be easy, but its a large pile of really terrible code which could be destabilizing, and would certainly distract from the core thrust of this PR. If you're interested in doing that, it should be a separate PR.

@swaroop-sridhar swaroop-sridhar merged commit daf720b into dotnet:master Jun 18, 2019
@swaroop-sridhar swaroop-sridhar deleted the model branch June 18, 2019 23:41
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…-setup#6831)

* Add AppHost Binary transformatuin Utilities to HostModel

The code that transforms AppHost binary in order to update the
path to the App.dll binary lives in multiple repositories
(SDK, CLI and partly in core-setup tests).

This change adds the code to HostModel library, so that other
copies can be removed.

This also facilitates implementing a similar mechanism to
locate the offset of the bundle header within the binary
(so that the bundle headers are not required to live at the end
of the file).

This change also adds the GetGUIBit method, as requested by the SDK team.


Commit migrated from dotnet/core-setup@daf720b
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants