Installing a windows service from a Visual Studio Installer project - visual-studio

A colleague has written a Windows Application and left me to do the installers. I have created the installer project through Visual Studio and added the primary output of the service project to the new project.
When I run the installer it creates the correct folders and copies the dlls, exe and config file in, but it doesn't do the actual install of the service.
The service isn't listed in the Services window, and if I double click on the exe I'm told I need to run installutil to install the service.
How do I make the installer do this bit for me? I found this article:
http://www.codeproject.com/KB/install/InstallService.aspx
but that seems overly complex for what I would expect to be pretty basic.

I used this article:
How to create a Setup project for a Windows Service in Visual Basic .NET or in Visual Basic 2005
Felt pretty dumb that I couldn't figure it all out until I went through all of the steps in this article. It's not a trivial exercise by any means.

For those who are looking for updated instructions for Visual Studio 2010 (instructions in answer are for VS 2005) check the following link:
Walkthrough: Creating a Windows Service Application in the Component Designer (note that "other versions" [VS 2005, VS2008] are available from the same link)

I had this issue in my case the problem was I neglected to add the custom actions for the installer project. To find these right click project->"view"->"custom actions" under there it needs the primary output added to the folders.

Related

Sign all needed files in Visual Studio and InstallShield

I'm using Visual Studio 2013 professional and InstallShield 2015 Limited Edition.
I have a SafeNet stick and I know how to sign files from the command line.
My Visual Studio solution contains 4 projects: unmanaged Dll, managed Dll (wrapper around the first one), wpf application and an installshield setup project.
My setup output is singleimage (setup.exe file) that contains everything what I need to run and use my application.
The question: how can I define installshield to sign ALL needed files and a setup.exe itself?
Google is not answering my question :(
Ok, I found the part of the solution.
1) In Release section of the setup project (in solution explorer) click on the SingleImage section.
2) At the right section you'll see three tabs, the last one is Signing tab.
The problem is that you need to provide the pfx file.
Creation this file from the SafeNet usb stick is my problem now :)
UPDATE:
My suggestion is to sign the files in post build events in Visual Studio Project properties.
After that sign the setup file and that's all.
I'll try avoid of using InstallShield builder :(

"This project is incompatible with the current version of Visual Studio"

I was getting the below message from Visual Studio 2010.
"This project is incompatible with the current version of Visual Studio"
One situation resulting in this error has already been posted here at Stackoverflow, but that question has been closed. I'm thinking it's a fairly generic problem. Since I have found a "solution", I'll post this question, and my solution as an answer.
If the message
This project is incompatible with the current version of Visual Studio
is due to an attempt to open a project targeting .Net 4.5, then the "solution" or workaround is to edit the .csproj file and change the TargetFrameworkVersion from "v4.5" to "v4.0". That at least allows the project to be loaded, although it may result in compiler errors if the program is dependent on 4.5 features.
VS 2012 has different project type support based on what you install at setup time and which edition you have. Certain options are available, e.g. web development tools, database development tools, etc. So if you're trying to open a web project but the web development tools weren't installed, it complains with this message.
This can happen if you create the project on another machine and try to open it on a new one. I figured it out trying to open an MVC project after I accidentally uninstalled the web tools.
I just got the same error message with a couple projects after installing Visual Studio 2015 Update 3. For me, the solution was to install .NET Core
In my case it was an incompatible Project Type. Editing project file and removing ProjectTypeGuids node resolved the issue of loading the project (I had already re-targeted the framework version as advised here).
Probably the project type is not supported in the (most likely) NEW version of VS, so you will have to adjust (update) the code to work properly (if possible), but at least you can see the content through VS.
I Resolved the issue by deleting the files in the below folder
%localappdata%\Microsoft\VisualStudio\12.0\ComponentModelCache
Source: https://forums.xamarin.com/discussion/70388/how-to-fix-incompatible-issue-after-visual-studio-2015-update-3
As for me, I realized there was another web project in the solution that my VS2017 was loading fine, so I copied over the ProjectTypeGuids element of it over to the project that wasn't loading. Its diff was:
- <ProjectTypeGuids>{E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
+ <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
After this, it loads. Don't ask me why.
If you are getting the same error for a project which is actually an extension (.vsix), installing Microsoft Visual Studio 2012 SDK does the trick.
Go to tools -> Extensions and updates -> Online -> Search for project installer -> download
And relaunch Visual studio.
After installing Update 3 for Visual Studio 2015, I suddenly got the "This project is incompatible with the current version of Visual Studio" error message while opening my Cordova project (.jsproj Javascript project file)
To solve this:
Go to Programs & Features
Select the Microsoft Visual Studio 2015 installation and click Change
Click Modify
Install "HTML/Javascript (Apache Cordova) Update 10" of the Cross Platform Mobile Development section
For me, I got this same error in VS 2015 and just installed the VS 2015 update 1, though from another answer, VS is actually up to Update 3, now (after which, they got the error and had to install .NET Core). Had issues when it hit certain packages, like the Windows SDK ones, and had to point the installer back at the paths in my original CD, and for some, even that didn't work and had to skip them and re-download from an internet-connected computer, transfer them over, and run them later manually (computer was not connected to the internet to be able to download updated versions of the packages), but after doing all that and doing a reboot, the error was gone and my project loaded fine.
I had this issue and after hours of uninstalling and reinstalling I found out the issue in my instance.
The reason why I got this was down to the fact that I didn't have the correct extension.
In my case the ASP.net project (my startup) was the incompatible project and this was because I didn't have the following:
Microsoft ASP.NET and Web Tools
Micrsoft ASP.NET Web Frameworks and Tools
It was a simple case of going into extensions and updates under the Tools menu
I had this error and found it was due to the presence an 'Import' XML tag inside the .csproj.user file. Once I removed it, Visual Studio could open the project again.
What most people forget it is that the files of visual studio are just text files, that have some peculiars configurations that will show to the program how to open it. that is, we can change this because it's just a text in some file in there in your project folders.
Well, knowing this, what we have to do is very simple!
The first step is knowing what kind of project it is this project that stay unload. (for example: Class Library)
The Second step is create a new one (Class Library) because you know that your visual studio will create a version supported by himself. Unload this one and click in "Edit csproj".
It's in this file that we can found the configuration that tell to VS how this proj will be loaded and his name is ProjectGuid, this serial number has a variation according the type and version of project.
Now, look at your "ok project", copy the "ProjectGuid" TAG, paste on csproj that unloaded, and pay attention to the little differences and make this files almost equals, except for the tags ItemGroup that represent the references of the project.
Doing that, save all files and close your VS and open again, now your project should load normally.
I hope that this informations help somebody to understand a bit more how the VS works and help solve the problems when necessary.
I checked if i could create a new solution and was unable because SSAS,SSIS and SSRS weren't there as options.
I downloaded SSDT from here and installed and it worked...
https://learn.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt?view=sql-server-2017
In case you came here looking for the issue with ".smproj" file, it is because you are missing SQL Server Analysis Services(SSAS). To over come this, install SQL Server Data Tools(SSDT) in your system, restart your Visual Studio and it will work.
Thanks.
This is my answer, I think it's useful. Please follow below steps:
1.First check your Visual studio version is 2012, 2015 or 2017 etc.
2.Your project is developed in 2015, but your visual studio 2012, then visual studio 2012 should not open the which are developed in visual studio 2015 projects.
3.If developed project visual studio 2012 and you have visual studio 2012, open the project but here need to check one option as per below
a) Target Framework - Open your project ".csproj" file with notepad++ and search with "TargetFrameworkVersion" and observe target framework value.
b) Open any existing project in your visual studio - Select project at 'Solution Explorer' - Right click - Properties - Application -Select Target Framework - Observe highest your framework which you have
c) 3.a and 3.b frameworks both are should same otherwise applications are not open
d)If your target framework less than the project framework should install the latest's
e) above options do not work just Simply have another option modify the "TargetFrameworkVersion" value in '.csproj' file which is have in your visual studio.
Ex: in my visual studio target framework 4.0 but in '.csproj' file have TargetFrameworkVersion - 4.5, You need just change 4.5 to 4.0 and open the project
This issue might be caused when using VS 2015 with Update 3 installed on one PC and without update 3 installed on another. This was the problem in my case.

how to make a uninstall option in C# program?

i want to make a uninstall option in my C# program?
can u help for this?
and provide some code also
If you deploy your application via a Visual Studio Setup and Deployment Project, an uninstaller will come standard with the installation. It will be available in the Add/Remove Programs of the control panel.
You can create an installation project which will automatically add support for uninstallation. Under Other Project Types you have Setup and Deployment. There is InstallShield LE and Visual Studio Installer. If you choose Setup Project under Visual Studio Installer project, you will have uninstall as part of the built project.
see this video
http://www.youtube.com/watch?v=Z-xFLltALg0
If you want the executable to remove itself. aka self-destruct. Check out this blog http://blog.pedroliska.com/2010/05/20/c-self-destruct-windows-app/

Can I manually install a windows service application using VS 2010 Express?

I have created a Windows Service Application and attempted to install it using installutil. But it doesn't show up in my services list. After doing a lot of research I concluded this is because I do not have access to the Setup Project template VS2010 Professional provides. I only have VS2010 express.
I need to mimic any code and configuration for installing a Windows Service Application but without creating a Setup Project in VS 2010. I only have VS2010 Express and want to toy around with creating a service for my home PC.
In other words, is it even possible to hand code what a Setup Project template provides in VS 2010?
If so, what are the essential steps? Are there any tutorials available for how to accomplish this?
Thanks.
the only thing you will need is a class which you will need to derive from ServiceBase and is instantiated from Program.cs.
Just compile and put your project output somewhere on your filesystem, open a command prompt and do InstallUtil your-assembly.exe.
Please note that you should use InstallUtil of .Net 4.0 (instead of 2.0).
On my PC, I use InstallUtil from C:\Windows\Microsoft.NET\Framework\v4.0.30319

How can I create an MSI setup?

I've created setups for all my Delphi tools with Inno Setup for years. Now some users rather want an MSI installation package, so they can deploy the setups from a central server to all workstations.
How do I create one? Do I have to buy Visual Studio or some other product?
You can use Wix (which is free) to create an MSI installation package.
WiX Tutorial - Creating an Installer MSI with Wix
If you don't understand Windows Installer then I highly recommend The Definitive Guide to Windows Installer. You can't really use WiX without understanding MSI. Also worth downloading is the Windows Installer 4.5 SDK.
If you don't want to learn the Windows Installer fundamentals, then you'll need some wizard type package to hide all the nitty gritty details and hold your hand. There are plenty of options, some more expensive than others.
InstallShield
Advanced Installer
MSI Factory
etc..
However still I'd suggest picking up the above book and taking some time to understand what's going on "under the hood", it'll really help you figure out what's going wrong when customers start complaining that something is broken with the setup :)
You can use Visual Studio - that's paid.
You can use https://www.advancedinstaller.com/ - that has a free edition.
You can use http://nsis.sourceforge.net/Main_Page - for example Winamp uses this installer - and is very configurable and is Open Source.
Google "Freeware MSI installer".
e.g. https://www.advancedinstaller.com/
Several options here:
http://rbytes.net/software/development_c/install-and-setup_s/
Though being Windows, most are "shareware" rather than truly free and open source.
In Visual Studio (including the free community editions) you can install the Microsoft Visual Studio Installer Projects extension [1] which allows you to create an MSI installation package. To install it from within Visual Studio:
Go to Extensions -> Manage Extensions in the menu bar
Search for Installer Projects in the search box
Select Microsoft Visual Studio Installer Projects and hit Download
Restart Visual Studio
Once the extension is installed, you'll create a new project that will contain all of the files and settings for the MSI. To do this:
Go to File -> New -> Project in the menu bar
Change the drop down menus visible to show All languages, All platforms, and All project types respectively
Scroll down in the project type list and towards the bottom select Setup Wizard: Create a Windows Installer project with the aid of a wizard.
Hit Next.
Work through the prompts to choose the installer project name and location. Choose Create a setup for a Windows application at Step 2 and in Step 3 choose the executable and other files that should be included in the MSI (hit Add..). At the end, hit Create.
To build the actual MSI go to Build -> Build Solution in the top menu, and you should see a message like the following in the Output window:
Build started...
------ Starting pre-build validation for project 'Setup1' ------
------ Pre-build validation for project 'Setup1' completed ------
------ Build started: Project: Setup1, Configuration: Debug ------
Building file 'C:\Users\zelda\Source\Repos\Setup1\Setup1\Debug\Setup1.msi'...
Packaging file 'test.exe'...
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
What's created by default is a very basic MSI, but for additional configuration like creating custom actions, adding/changing registry keys, configuring the user interface associated with the MSI, etc., see the full documentation [2]
[1] https://marketplace.visualstudio.com/items?itemName=VisualStudioClient.MicrosoftVisualStudio2017InstallerProjects
[2] https://aka.ms/vdproj-docs
You can use "Visual studio installer project" and its free...
This is very easy to create installer and has GUI.(Most of the freeware MSI creation tool does not have a GUI part)
You will find many tutorials to create an installer easily on the internet
To install. just search Visual Studio Installer Project in your Visual Studio
Visual Studio-> Tools-> Extensions&updates ->search Visual Studio Installer Project. Download it and enjoy...
Look for Windows Installer XML (WiX)
You can purchase InstallShield, the market leader for creating installation packages. It offers many features beyond what you get with freeware solutions.
Warning: InstallShield is insanely expensive!
In my opinion you should use Wix#, which nicely hides most of the complexity of building an MSI installation pacakge.
It allows you to perform all possible kinds of customization using a more easier language compared to WiX.

Resources