question

BelarminoVicenzo avatar image
0 Votes"
BelarminoVicenzo asked cooldadtx answered

Extract self-contained file in a specific directory

I have made a Windows Service and every time we test on different machines, we have a .NET runtime error, because not all machines we have have that installed.

So we've published it as a Self-Contained.
Well, the problem is, that we have json configuration files that aren't going with the extraction.

When open, it creates some folder like this

C:\Users\User*AppData\Local\Temp.net*AppName*randomName*

But it doesn't take our config files and some useres have difficulties using it. And I also read thing saying that Windows deletes that folder, so it wouldn't be good after some months, files that folder in temp are gone or partially gone.

So I wanted to know, if I can extract the self-contained file to a specific directory and if possible choose to include the config files in this extraction.
Like saying extract to C:\AppName and run it from there.


Windows services running from self-contained apps get files cleaned up from %TEMP% under them




dotnet-aspnet-core-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

cooldadtx avatar image
0 Votes"
cooldadtx answered

It's a window service which means users would need to install it as a service to run it. That requires admin privileges. Create a setup program to install your service. As part of the setup project you'll specify the files you need and you'll include the config/settings files as part of that. The end user will run the installer (as an admin) to install the service and that will register everything with Windows and copy all the files correctly.

If you don't actually mean a windows service but rather a regular windows app then use ClickOnce to build an installer instead. Or just zip up the output directory of your build as it'll contain all the files that are needed. Then you can use your favorite archive tool to create a self-extracting zip file. When the archive extracts it'll put whatever files were in the zip onto the user's machine. Since you zipped up the output directory of your app it should contain everything that is needed.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.