-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
UseWindowsService doesn't work correctly with single file executables #36065
Comments
Describe the bugThe previous workaround does not work anymore with To ReproduceSteps to reproduce the behavior:
Expected behaviorThe ScreenshotsEventViewerAdditional context
|
Oof, the issue is that We need to think a bit about this scenario. Thoughts @davidfowl ? |
@vitek-karas @elinor-fung Is there a way to detect when we've been "expanded" from a single-file exe and to get back the path of the original single-file exe? Perhaps using |
If that doesn't work, we're going to have to make sure this design works with the newer single-file plan in 5.0. |
@anurse To get the directory containing the actual single-file app, you can use: |
Is there also a way to detect when we're launched as a single-file app? Or would it be reasonable to use |
Linking https://github.com/dotnet/core-setup/issues/7491 for transparency. If the runtime adopts the behavior described in the design document this issue could likely be closed without action..
|
Yes @dasMulli, the intention in the next version is for the @anurse, I agree that an API to detect whether running from a single-file is useful in certain cases. There's a proposal in the design to add this API in the next version. |
I'd definitely prefer solving this via https://github.com/dotnet/core-setup/issues/7491
Given this, I'm going to mark this as External but leave it open for us to verify as 5.0 develops and we have the new single-file bundling logic to test out. |
I think it would be very good if we can set the content root from application. Something like this :
|
@BurhanEyimaya You can, just need to make sure to call is after |
Just fyi, |
Not blocking release of 5.0 product. |
Closing issue as resolved on .NET 5.0. @xt0rted if this gets repro on 5.0 we could reopen it again. |
Describe the bug
.UseWindowsService()
sets the base path toAppContext.BaseDirectory
which ends up being something likeC:\Windows\Temp\.net\FileUploader\blc0j22k.v0p
when using a single file exe and running as a service. This prevents theappsettings.json
files from being loaded if they're saved alongside the exe which I've been told is an acceptable deployment scenario.To Reproduce
Steps to reproduce the behavior:
3.0.0-preview7.19362.4
of packageMicrosoft.Extensions.Hosting.WindowsServices
appsettings.json
with a setting in it.ConfigureServices(ctx, services)
callctx.Configuration.GetValue<string>("SomeValue")
dotnet publish --configuration Release --output artifacts /p:PublishSingleFile=true /p:PublishTrimmed=true
appsettings.json
will not be loadedExpected behavior
The
appsettings.json
stored alongside the exe should be loaded when running a single file exe as a service.Current workaround
I originally was using the following code before I added in the
Microsoft.Extensions.Hosting.WindowsServices
package which I got from the asp.net core 2.2 docs:After adding this package I modified the code like so:
Depending on how you publish the application this might not be a bug but rather a documentation note. It seems worth mentioning though.
The text was updated successfully, but these errors were encountered: