I currently have a windows service that needs to run in the background while a main application I have written handles UI and other tasks. I install and maintain the GUI application using ClickOnce Deployment and would like to find a way to bundle my Windows Service in as well.
They are in separate projects at the moment since I was still learning how to use the Windows Service.
My question is, is it possible given MyService.exe that I install and start MyService.exe from MyApp.exe? I can assume that I have access to InstallUtil.exe and could write a script to install and run it manually, but I would like a cleaner solution if there is one.
The only resources I've found all seem to assume I want to have the Service install itself, which is not the case.
In general, ClickOnce can't be used to install services. There is typically a lack of permissions, but also the location is incorrect, etc. For details, see MSDN on Choosing Between ClickOnce and Windows Installer for more details.
If you want to install a service, you should do a traditional installation.
Related
I have a wpf desktop application (ERP) system
Application is using setup and deployment to create the .exe file
Now, i want to create a window service for my application to do some background check ups , synchronizations with my database etc.
I know how to create a service in.net and how manually to install it following the examples online.
My question is how i can install (or include let's say) this service within my .exe setup.
I don't want the user to be responsible to install the service.
Neither me to login every time someone pc to install the service
Not sure if i misunderstood the purpose of service but i found nothing online related to my question.
You can use Microsoft Visual Studio Installer Projects and include your service/main project at the same time
https://marketplace.visualstudio.com/items?itemName=VisualStudioClient.MicrosoftVisualStudio2017InstallerProjects
We have a web app and a desktop windows WPF app.
Windows app sends data to webapp (hosted on azure)
Users download app from website. There are occasionally new versions of desktop apps available.
What is the most efficient way to setup automatic updates for desktop app? We are using github.
I found "releases" in github but I'm not sure how to notify desktop app and how to create an updater. (I guess we need to check for github releases every time app is started. Do I need to use Github api for this?)
What is the best repository structure for releases?
I'm looking for best practicies on how to perform seamless updates to desktop apps. (In terms of repository setup, creating web api to pull version info maybe?)
You can deploy your desktop applications using ClickOnce Deployment mechanism. This will take care of updating the software. Your users download the software from a publicly accessible Internet site. Whenever you have a new version available, you can simply deploy the latest deployment files on the download link. ClickOnce deployed application automatically check for any updated version on that link and prompt the user to download and install the latest version.
From the same MSDN link, one of the problems solved by ClickOnce deployment is facilitating automated updates:
Difficulties in updating applications. With Microsoft Windows
Installer deployment, whenever an application is updated, the user
must reinstall the whole application; with ClickOnce deployment, you
can provide updates automatically. Only those parts of the application
that have changed are downloaded, and then the full, updated
application is reinstalled from a new side-by-side folder.
I was looking into accomplishing the same needs and came across this library which can do what you're asking for;
https://github.com/Squirrel/Squirrel.Windows
There's a lot of configuration, but what you're asking for is not trivial, but maybe you can get some ideas.
For our needs; we're going have our build server (teamcity) create an MSI using a Wix project then the app will download and execute the MSI. Once we go to production we'll move MSI hosting over to some more enterprise-y CDN type setup.
Actually I want to run exe file(My Job.exe) Through window Service in C# but window service should be started automatically when I start the Computer?
I have already added Window Service (MyService) manually. I have also setup project of My application where I also added this service so that I can also be installed when I install my Application.
I have serviceInstaller1 with property
StartType=Automatic;ServiceName=MyService.
I also have serviceProcessInstaller1 with Property
Account=LocalSystem;
When I run this my Applicationo gets installed but MyService don't get installed and I also not see it in Service of Computer Management.
Could any body please help me I already spend two days on it but not finding proper guidline. thanks in Advance.
How is your application being installed? Did you create an installer (.msi file) for it? It sounds like you're trying to implement your own installer instead of using existing tool to do this.
I recommend Advanced Installer. It is a very powerful installer generator and has all the features you need in the free version, and more importantly, it's very easy to use. This tool lets you create an install wizard with the ability to patch and uninstall your software (including services, registry values, files, etc).
I recently have one project with windows service in VS2010 and .Net 4.5 and user OS will be Windows Server 2008. I was unable to create fully functional installation a long time, and still i dont have, but request are changed so no need for installation file. But i can give you advice "How to do".
If you don't have purchased version of InstallShield you need to find some other program for creating installation file.
For installation you need just to copy you .exe output of service and one batch file witch will have next content:
#ECHO off
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe" "%~dp0%<filename>.exe"
pause
and then you need to run with administration rights this batch file.
Both files (.exe and .bat) must be in same folder.
You can delete pause command but then you will not see if registration of service was successfully.
Make sure that you have installed target .NET Framework on PC.
I hope that this will help you.
If you just need to run your exe file(My Job.exe) when the system starts up you could add your exe to the Windows Task Scheduler.
Is there any specific purpose for using a Windows service?
The reason that I am saying this is that you have a wide variety of options to invoke you exe as follows
Schedule based on common recurring events, i.e. When the computer starts or When a user logs on.
Schedule based on the calendar, i.e. Daily, Weekly, Monthly, or One time.
Advanced options like execution based on events, etc.
My App will be initially deployed with Windows Installer.
The key characteristics of the solution I am looking for include:
Support silent update while app is
running (or automatically restart
client)
Easy to maintain and manage packing
process
Avoid complex customizations or
installation scripts
Do you have any ideas on how can I achieve this? Even if it means to modify the app code to support any idea.
Application is .net 2.0
Have you considered using ClickOnce for deployment? It has a facility to programatically check for updates and optionally force them to be installed - see http://msdn.microsoft.com/en-us/library/ms404263.aspx
You can silently update your application by using the Restart Manager (available in Vista and Win7).
Don't forget that a user is not alway the administrator. Since Vista if you sign your Windows Installer package you can update the application without needing administrator rights from the current user.
For all this to work you need to install your application using the Windows Installer technology. You can use Wix to create an xml file and compile it to an .msi package. Wix integrates nicely with VS.
The Proxy Design Pattern will help you achieve this while this is the pattern used for plugins.
Another short explanation is with the Gang of Four - Proxy Design Pattern.
Having an eye out the Shadow Copying of assemblies is definitely useful for the trick, as you shadow copy your updated assembly to your application assemblies folder, then you can make your application aware of changes, then unload the old assembly and load the new one for the changes to take effect, that is, without even having to restart your application, and this will be absolutely transparent for the end-user.
A more simple approach might be the ClickOnce Deployment which you might be interested to read about following the sugested link.
I currently have a VS Solution with 2 projects: a WPF application and a Windows Service.
Now, I have managed to get ClickOnce working in installing my WPF application, but I also want a Windows Service to be installed (the one in the project) during this installation.
I have found ways how to programmatically start a windows service with C# code, but is there any way to incorporate this in my ClickOnce installation (because I need ClickOnce's benefit of automatic updates and such)?
I don't think you can deploy a windows service via ClickOnce in a normal fashion.
http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/1bb64760-9622-4ca6-a1a6-3ce53e641f21
ClickOnce deploy a Windows Service?
Please check DDay Update library it might give you ClickOnce stuff for updates, but first install you've got to do using another too.
Can you execute a process during the ClickOnce install? You might be able to write the service using Topshelf and then execute MyService.exe /install from ClickOnce.