Skip to content
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

How do I package the dotnet runtime with my apps? #75

Open
ferenc-a opened this issue Jan 8, 2025 · 14 comments
Open

How do I package the dotnet runtime with my apps? #75

ferenc-a opened this issue Jan 8, 2025 · 14 comments

Comments

@ferenc-a
Copy link

ferenc-a commented Jan 8, 2025

I've been following this example: https://github.com/nulastudio/NetBeauty2?tab=readme-ov-file#customize-apphost.
I thought the "shared runtime" meant that somehow the dotnet runtime is packaged by NetBeauty, but that doesn't seem to be the case.
I also want to package a single instance of ASP.NET Core Runtime with my app set, that all apps would find, and doesn't need to be installed. Can I achieve this with NetBeauty?

@liesauer
Copy link
Member

you should use the self-contained deployment mode with shared runtime enabled

@liesauer
Copy link
Member

@ferenc-a
Copy link
Author

ferenc-a commented Jan 10, 2025

It works, thanks!
I have an issue though: if I ony specify --self-contained on publish, not on build, the app fails to run with No frameworks were found..., as if there were no framework at all.
The difference between the two published folders (one with --self-contained build, one without) is only in the runtimeconfig.json and the main dll, all else is the same, the runtime is also present in both cases.

I want only my publish to be self-contained, not my whole build, so that I don't have a separate instance of the runtime for each app at every CI build step, only on publish.

@ferenc-a
Copy link
Author

ferenc-a commented Jan 17, 2025

Could you help me solve this, so I won't need to add --self-contained to builds too?

@liesauer
Copy link
Member

typically, we should turn off NetBeauty when on build

<BeautyOnPublishOnly>True</BeautyOnPublishOnly>

@ferenc-a
Copy link
Author

I already have that set. That's not the issue.

My problem is when I build without --self-contained, then publish with --self-contained, the app fails at launch.
I could add --self-contained to both build and publish to fix this. But I want to avoid that, because I build often and this makes builds take up more space and slower.
NetBeauty copies basically all the right files in the first scenario too (no --self-contained for build), but it gets something wrong and the app fails at launch.

(By build and publish, I mean running dotnet build and dotnet publish specifically).

@liesauer
Copy link
Member

did you run the command via cmd/powershell or using the visual studio? this shouldn't happen, unless the dotnet reuses the built files.

@liesauer
Copy link
Member

can you provide a demo so i can have a deep look on it.

@ferenc-a
Copy link
Author

I ran it in a shell. It does reuse build files, I also pass --no-build to publish. Is that not supported?

@liesauer
Copy link
Member

i can't tell, but build without --self-contained, and then publish with --self-contained, there must be something different and this behaivor has changes to break NetBeauty, have you try deleting obj and bin before publishing the app?

@ferenc-a
Copy link
Author

What do you want me to do exactly? I tried this:

  1. build without --self-contained
  2. delete the obj directory
  3. publish with --self-contained and with --no-build

But my publish just failed: error NETSDK1004: Assets file ...\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
I haven't tried deleting the object dir before, but I did all my previous bug repros with clean obj and bin directories.

@liesauer
Copy link
Member

try deleting obj and bin before running dotnet publish

@ferenc-a
Copy link
Author

If I delete the obj and bin directory and add --no-build to publish, it just fails with the error I said. I tried what you said, does not work.

If I don't add --no-build it works fine. I ask again, is --no-build not supported?

@liesauer
Copy link
Member

you are right, --no-build is unsupported

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

2 participants