-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 to share self contained runtime? #52974
Comments
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov Issue DetailsI have two projects targeting the same runtime. I publish the first one as self contained and copy the second application into the same folder of the first one. But the second won't launch saying the required .NET Core runtime is not installed. How can apps share the same self contained runtime? area-Host
|
By definition self-contained app does not share. I think using shared .NET installation is best option for you @ |
@AaronRobinsonMSFT The discussion you linked to is about targeting different runtimes where it makes sense to say its not supported. But I target exactly the same runtime, where it makes no sense why it cannot be shared. @wfurt Thanks but an installation is not an option. For example because on some machines you are not allowed to install. Self contained is just a simple whole .NET runtime copy to folder. If there is no support for having two applications using the same runtime yet, then it might be worth to add support for it. Why shouldn't I be allowed to use the same runtime there but instead being told I have to install .NET runtime to a folder which is then shared by all applications. That not really makes any sense. I believe when self contained feature was created, nobody simply thought about this "issue" and so it currently doesn't work. But that doesn't mean it cannot be changed / fixed. //edit: Funny, all it needs to make it work is editing two JSON files for the second application. |
I'm perhaps wrong person to argue this but but sharing clearly breaks the self-contain app promise IMHO. How is putting runtime to separate directory different from bringing it with the app? You can even have tat directory be part of your application deployment. For sharing the runtime bits, the shared runtime strategy seems to be good fit. |
@Symbai - I agree that for simple apps there doesn't seem to be a problem - and if you published both as self-contained and then just copied app.dll/.exe/.deps.json from one to the other it will probably just work. But it doesn't mean it's easy to make this work reliably. Self-contained is not just about including the runtime:
If you "copy over" these things won't happen and it can easily break. For example if app1 has a dependency on MyDll.dll version 1.0.0.0, but app2 has a dependency on MyDll.dll version 2.0.0.0, you would have to carefully choose which one to use. Also to fully support this, the result would need to support features like Ready2Run, Trimming and so on - none of these will just work. For scenarios like yours where you have multiple applications and want to ship a shared runtime for them, I 100% agree with @wfurt . Building the apps as framework-dependent and packaging the runtime with both apps is currently the better solution. Right now it's possible but not easy:
In both cases there's an additional complexity of getting the right runtime downloaded (you want the zipped version for the right platform) and shipping that with your app - but since it's just xcopy deployment, it should not be that hard. The advantage of this approach is that:
We're thinking about adding better support for this kind of scenario in future versions. It would help us if you could describe what type of apps you're building, why is it OK to package them together and why do you want custom runtime copy. Just so that we have our reasoning correct. |
Ok I didn't thought about assembly versions, that makes sense. In my case I have an app and a standalone updater (console application) that overwrites the main application files if there is an update available. Very simple but necessary. I think that writing an own native host is a bit over the top. And I think that my request can still be done. The versions / conflicts can be checked and a publish error can be thrown if there is a conflict. Alternatively there should be an easier way to tell the native host where the runtime is located, this will also solve the other issue about file clutter where people requested to move runtime files into a different folder. Maybe this can be done via a build command line which "patches" the native host. Something like:
Then I can publish the first application self contained. And use the args above on the second application publishing it framework dependent and copy it over. |
Both solutions are doable, it's just a question of cost (not just the work, but if it's worth the future maintenance and added complexity).
This would still not work, even if the apphost can point to a different location for the runtime. Again, it could be made to work, but I don't think that is desirable. It would be much cleaner to have both apps as framework dependent but share the same runtime folder. |
Still need that build argument above. And something that copies the runtime to that folder as well. Then I'm absolutely fine with its being framework dependent. |
Closing in favor of #53834 |
I have two projects targeting the same runtime. I publish the first one as self contained and copy the second application into the same folder of the first one. But the second won't launch saying the required .NET Core runtime is not installed.
How can apps share the same self contained runtime?
area-Host
The text was updated successfully, but these errors were encountered: