How do I package the dotnet runtime with my apps?
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?
you should use the self-contained deployment mode with shared runtime enabled
check this example, https://github.com/nulastudio/NetBeauty2/tree/master/NetBeautyTest
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.
Could you help me solve this, so I won't need to add --self-contained to builds too?
typically, we should turn off NetBeauty when on build
<BeautyOnPublishOnly>True</BeautyOnPublishOnly>
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).
did you run the command via cmd/powershell or using the visual studio? this shouldn't happen, unless the dotnet reuses the built files.
can you provide a demo so i can have a deep look on it.
I ran it in a shell. It does reuse build files, I also pass --no-build to publish. Is that not supported?
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?
What do you want me to do exactly? I tried this:
- build without
--self-contained - delete the obj directory
- publish with
--self-containedand 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.
try deleting obj and bin before running dotnet publish
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?
you are right, --no-build is unsupported