Visual Studio Advanced Installer - Install a Windows Service with build transforms - visual-studio

I have a .Net 4.7 application which is developed as a windows service. I have an MSI project which does the installation and there is a post install activation script that also gets executed (manually).
I am trying to replicate the old installer using the Advanced Installer Extension in Visual Studio and cant resolve these issues.
The first one is how do I stop Advanced Installer from creating multiple subdirectories in the target installation location. The install parameters have the Application folder set to [ProgramFilesFolder][Manufacturer][ProductName] however, I am getting [ProgramFilesFolder][Manufacturer][ProductName][ProductName]. I have the project Output under the Application folder in the files and folders tab.
Secondly, how do I install the application as a Windows Service. I can see this in the external version of Advanced Installer when I create a new package, but can't find the settings for the one within Visual Studio for the existing package.

Within Advanced Installer extension for VS you cannot configure the install location template, nor a service installation. As you already noticed those settings are available only in the desktop version of Advanced Installer.
As a workaround you can use the [Edit in Advanced Installer] button from VS and then edit the install location template from Install Parameters view in Advanced Installer desktop app.
Also, while in Advanced Installer desktop app you can configure a service installation as exposed in this tutorial.

Related

Open a Windows app programmatically, when it was installed with MSIX Application Packager

I have packaged my windows App using a Visual Studio MSIX Packaging Project: This is a sideloading app, using a certificate, not a Microsoft Store App.
This is fine - I get automatic updates, and users can install the package without admin rights.
I want to be able to open this app from another app.
Before this was easy - just call Process.Start with the app path: "C:\Program Files\MyCompany\MyApp.exe"
However the Executable for an MSIX installed app is hidden I suspect its in "C:\Program Files\WindowsApps" but this folder is restricted and I can't get access even with admin permissions
There appears to be some data about the installation in C:\Users\MyUser\AppData\Local\Packages{myappguid} - but no executable files are available here.
So my question is simple: How can I launch an app from another program, when the app was installed using the MSIX application packager?
This turned out to be fairly simple.
Edit your Package.appmanifest and add the following in the Application element
<Extensions>
<uap5:Extension Category="windows.appExecutionAlias">
<uap5:AppExecutionAlias>
<uap5:ExecutionAlias Alias="MyApp.exe"/>
</uap5:AppExecutionAlias>
</uap5:Extension>
</Extensions>
And ensure this namespace is referenced at the top of the manifest file xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
and is in the ignorable namespaces too.
Rebuild and re-install the MSIX.
Test at a new command-prompt - just type MyApp.exe - it should open the app.
Now the second program can execute Process.Start("MyApp.exe") and it works.
Reference: https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-uap5-extension

How to Deploy a Windows Service using Visual Studio 2017 Community

Working with VS2017 Community I have written a service that works on my local machine. I followed the instruction here:
https://learn.microsoft.com/en-us/dotnet/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer
and installed it successfully using Installutil.exe (as per instructions in above link). All good.
I now want to deploy that across six servers in our organisation. In Microsoft's documentation about installing services (https://learn.microsoft.com/en-us/dotnet/framework/windows-services/how-to-install-and-uninstall-services) it says:
If you’re a developer who wants to release a Windows Service that users can install and uninstall you should use InstallShield
and links to a page that applies to VS2012 (can't post any more links as my reputation<10)
I have downloaded and installed the "Microsoft Visual Studio 2017 Installer Projects" package, which allows me to create a Setup Project. When I run it, it installs the project output correctly (i.e. copies the exe & dll files to the correct folder in Program Files) but does not create the service.
There's a detailed post about deploying services on this site (question 9021075) but when I follow those instructions I get a 1001 error on Install.
All the documentation I can find refers to earlier versions of VS or the previous Installer package, so I'm not even certain if I can do it with the software I am using.
So, with VS2017 Community using Microsoft Visual Studio 2017 Installer Projects, how to I create a stand-alone Installer to deploy a service that works correctly when installed locally using InstallUtil?
Or can I use InstallUtil on the target machines? I think I'd need to install Visual Studio on them for that, which I'd prefer not to. Is there a quicker way?
I only have 6 servers to install this on, so even some manual work-around might do.
Thank you for the responses. I now have a solution. I found InstallUtil on the Target Server (in my case it was in C:\Windows\Microsoft.NET\Framework64\v4.0.30319 but search will find it). I copied and added that to my project as content so when I now deploy it, I have InstallUtil in the same folder as my EXE.
To install, I run CMD as admin, cd to project folder and issue command:
installutil.exe myService.exe
This is a one-off task. Once the service is working, to update it I just need to stop it, upload the new myService.exe (& any DLLs) to overwrite the old ones and restart it again.
Further information about settings you're using for the serviceProcessInstaller1 and serviceInstaller1 files will be needed to debug this issue, as the 1001 error raised by the installer is a generic error.
An alternative way of doing this is to use Topshelf, which is a framework for hosting services written using the .NET framework. It simplifies the creation of services, allowing developers to create a simple console application that can be installed as a service using Topshelf. The reason for this is simple: It is far easier to debug a console application than a service. And once the application is tested and ready for production, Topshelf makes it easy to install the application as a service.
Alternatively, you could use InstallUtil.exe. It is part of the .NET Framework, so no need to install Visual Studio.

How Do I configure my setup in Visual Studio 2010 using Visual Studio installer to check for updates?

I have built an Application using visual studio 2010 and a setup using the Visual Studio installer. Now what I want is whenever the exe is installed on a client machine it should check for updates regularly.
Any Suggestions . Please Help.
It's my experience that most people do this in the app itself, so that when it runs it checks your web site for updates.
Basically you need a web service call to which your app passes the ProductCode and Version of your setup, your MSI file build. At your web host you need a database (or Xml file) that has information on the latest available version and it's download location so that you can return that information to your app, assuming the latest version is higher than the running one.
You're in Visual Studio, so you build a RemovePreviousVersions updated MSI, and that's what you download and install. If the install needs admin rights and your app isn't elevated than you'd launch an external exe with an elevation manifest to get it installed.
I just finished a project similar to this, but instead of using Visual Studio installer libraries, I created a windows service that runs on a 10 minute loop, and when the service detects a new version, it kills the running application and performs a download and copies the new files into the application folder.
There are a few things you need to take into consideration; 1) A way to gracefully warn and then close the application so the user is not angry over a forced kill of the application. 2) A web location to store the upgraded application files, and a web service to advertise the available application versions. 3) A way to queue the upgrades so that when a new version is released not every client will be upgraded at once (flooding your web server with upgrade requests and downloads).
This technique is used by Adobe for upgrading and installing applications such as Acrobat Reader and Flash.

Building an installer that runs another installer

My company has a project for which I've developed an application in c#. I can create an installer for that application. However, the project requires users to install another application built in c++ that has an installer built using Visual Studio 10. Is there a way that I can build an installer that includes installation of the second product before installing my application?
What you are looking for is a bootstrapper or chainer. The WiX Toolset provides this functionality in a tool called Burn. It allows you to provide a single user experience while installing all of your setup packages. You can read about it more in WiX .chm.

Executing VB6 exe in non-VB environment

I have created a Vb application/exe using ADODC components and common dialog box. but I am not able to run that application on another PC where VB6 is not installed.
Do I have to install some additional components on that PC? (Don't want to install VB6 there).
How can I configure ODBC connection using code which we do manually from Control Panel -> Administrative Tools -> Data Sources -> Add new -> mdb ?
You should use the VB6 Package & Deployment wizard to generate an installer that will embed all the requirements and dependencies that your application needs to run.
That wizard is part of the VB6 development environment. Check the VB Start menu folder to find it.
Install the comdlg32 manually following the instructions on this site
http://devonenote.com/2010/02/register-comdlg32-ocx-on-x64-win7/
comdlg32 was not included in Vista and up.
NOTE Notice the different location to drop the file if it is a 64bit OS. And it may require you to run regsvr32.exe as administrator. Just follow the instructions on the link above. Should work.

Resources