-
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
PublishSingleFile with Windows Service doesn't work with config-file #32735
Comments
@ststeiger In order for the application's settings to be editable by users as a separate file, and survive across app-builds, it is best kept separate from the app. So, excluding the Once That is, in a single-file app, the location of assemblies is abstract. The fact that assemblies are extracted to a temp-location (I believe this is what you mean by shadow-copy location) is a matter of implementation. In .net 5, there will be no extraction, or a disk-path associated with assemblies bundled into a single-file app. So, apps need to be aware of the fact that If you use WebSDK, all this work (including exclusion of |
Ah, I see, this is again like in the 2.x series, where the current working directory was set to system32. That got me there, too.
I'll just have to use May I use this opportunity to say I find it strange that the template for worker/service doesn't by default add the Not that I mind adding it, but if I need to google it from 3rd party blogs, to get microsoft software to work on the microsoft OS, and in addition have to figure out that since the blog was written, the method's name has changed to "UseWindowsService", then it's badly documented. Why not just include this in the template ?
|
Correct, thanks.
Can you please file a CLI template/documentation issue about this in the SDK repo? |
Related: #3704 |
I believe there's no further action required on this issue. |
@ststeiger May I ask which template you used to create your service? I want to make sure we find the right people to at least get them your feedback about the template lacking Windows-Service integration. |
My understanding was that @ststeiger used |
@vitek-karas: Worker-Template in JetBrains Rider, which should use the same template as Visual Studio, assuming the template is licensed to be reused.
OK, filed issue 10724 in SDK repo.
Correct :) Though theoretically, since at least theoretically, somebody could be interested in attributes, it should probably be configurable with a default of content-only - for sanity - or with a default to content&attributes for backwards-compatibility. This should probably be a separate issue though. |
Note that System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName is "C:\Program Files\dotnet\dotnet.exe" when debugging (and when executing with dotnet). So fully correct is:
|
The PublishSingleFile option is rubbish.
I have a windows-service - simplified code posted below.
That windows service has an appsettings.json file, posted below.
In that config file, I can set the the query interval and the GlobalMemoryStatusEx memory limit.
The code of the service is basically
As you can see in the code, I listen for changes in the appsetings.json file, and update the two member variables m_maxLoadRatioBeforeKill and m_measureInterval (by the way this bug from Jan 2 2018 is still not fixed, and ms-bot closed and blocked the issue... if you/Microsoft want to destroy github-issues and github, just keep that up... are you seriously trying to reanimate microsoft-connect ? Aka Closed as won't fix ?).
Now this works fine (after
private async System.Threading.Tasks.Task IgnoreIrrelevantFileAttributeUpdate()
, which is obviously an open issue with filewatcher since ancient times, but not my actual problem)Now, if I set PublishSingleFile to true, either there is no appsettings.json in the publish directory, and appsettings.json is zipped together with the executable and copied to whereever shadowcopy copies that crap.
or I set
as discussed here and here.
Now I have the appsettings.json file separately, but...
Now there is no appsettings.json file read (or shadow-copied), and the service just executes at an interval of 0 millisenconds...
Hilarious - if I hadn't to get it to work NOW...
How is that supposed to work if I update the config file in the install directory of the single-file windows service when it goes into production ? (Note: the install directory, not the shadow-copy directory)
Maybe instead of zipping and shadow-copying, you should actually do static linking, so you don't need to shadow-copy ?
You know, like in golang ?
Because if you don't, you'll never run out of issues like this.
(The next issue would certainly be native libraries, but as I can see now, it fails long before that )
Also, how can I do this correctly ?
Obviously,
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
is not the way to go.
So what can I do, when I want to publish as single file >without< loosing the ability to update appsettings.json on the fly ?
appsettings.json
Worker.cs
Program.cs
The text was updated successfully, but these errors were encountered: