Process of ClickOnce and prerequisites - c#

I have an application I want to build and deploy via ClickOnce. But we want this to be a process that can be run outside of VS through scripts, for either test, business UAT or production environment.
Each separate environment requires a different .config file to be used and a different web server to be deployed on and for update location.
The application also has prerequisites of .NET runtime 3.5 and Crystal reports.
I have looked into using MAGE to create application and deployment manifests, and if I do a code BUILD, then use MAGE afterwards as per each environment, as well as having the script copy over the correct .config file, this creates what I think are the correct manifests for each environment at the time of running the script.
But what I'm struggling to do is include the prerequisites. If done through VS, you can specify a setup.exe package which gets built with the pre-reqs and deployed alongside the application and when you click on the download link, it installs the pre-reqs from setup.exe and then the application.
But how can I do this manually outside VS? I can build the setup.exe through VS with the right URl location but then how do I link the setup.exe to the application as a pre-req using MAGE to generate the manifests?
The problems we have are 1) The users do not have admin rights to download and install packages, only to install things via clickonce so the pre-reqs have to be installed under the click once security umbrella.
Thanks

ClickOnce and prereqs cause lots of confusion. The setup.exe that Visual Studio generates has nothing to do with ClickOnce. The only minor link between the two is that the setup.exe will launch the ClickOnce application once it finishes. That's it. So thinking users will be able to install your prereqs "under the clickonce security umbrella" is a mistake. If they are not an admin and a prereq install requires admin privileges, they won't be able to install it.
My advice would be to generate your setup.exe one time. You shouldn't need to keep doing it unless your prereqs keep changing. Use Visual Studio, generate the setup one time, then use Mage for the rest.
Edit
In general you make the setup.exe available and depend on the user to know if they need to run it or not. If they already have the prereqs and run the setup.exe, nothing bad happens. It sees that everything is installed then launches the app.
Usually you're going to direct users to run the setup.exe. The next time they want to launch the app they should use the start menu shortcut (assuming you didn't go with "Online Only"). I've found this to be the least confusing set of instructions for users.
Remember how Visual Studio does extra, non-ClickOnce stuff when you publish (like the setup.exe)? It also creates a simple html page that has links to both the ClickOnce manifest and the setup.exe and an explanation. It also has some javascript that checks the UserAgent string to determine if they have the .NET Framework installed. Again, this isn't ClickOnce. It's just something nice Visual Studio does for you. If you like it, use it. I kind of like skipping it and going with the run setup.exe to install then launch from the start menu.

codeConcussion is right, you can't ever actually have the prerequisites instill directly from ClickOnce. You should just generate it once and then you have it ready for your external ClickOnce tool.
There is an option other than Mage. You could use my companies tool, ClickOnceMore, as your ClickOnce build software. It's been designed for people who want to use ClickOnce but don't want to build with Visual Studio.
It can hook into the setup.exe generated from Visual Studio (details here) so should satisfy all your needs.

Why do you want to build setup manually if everything can be done via clickonce ?
You can select "Download pre-requisites from same location" option from prerequisites form if you want to include .netfx or crystalreports, download bootstrap packages for .netfx3.5 & crystalreports and add to folder (for windows 7) "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages" . The deployment project will automatically include netfx & other packages along with setup.exe.
hope this helps.

Related

How to release a project with dlls and packages used in it in Visual Studio C# to use it on another PC?

I've just finished my Windows Forms App project in Visual Studio using C#. I know I need to release it. To do so I need to go from Debug mode to Release above in VS and then just click on F6. After that I have a folder with an exe file in it. But in my project I use a dll library which was copied on my PC and registered by regsvr32.exe in cmd. Next in VS I went to Solution Explorer and added the library in References by writing the path to it. I also use two packages which were installed by NuGet Package Manager.
My program is developed to use it by my coworkers so I have to distribute it to them. The problem is that I don't know how to prepare my app for it.
I'm reading lots of different articles about the release step but I'm getting more confused. People usually write that I can just copy the exe file in the release folder and use it in another PC after installing .Net there. But in my project there are also the three libraries and without them my program won't work in another PC. I can copy and register the first library on other computers but what about the last two? How to set up them correctly?
About the first library, I put it in a folder created by me manually in the C directory of my computer. The release folder is in another place. And when registering this library in cmd and then adding it to References, I specified the path to it. It means if the path has been changed, it won't be possible to use the library in the project. I tried some times. It's not convenient and when placing the app in another PC without VS where I can specify the path, my program won't probably work. So it would be very convenient to place this library next to the release folder and after putting it in another PC, the path to the library wouldn't cause any problems.
To sum up, I'm looking for the way to easily and conveniently distribute my program to users. Of course, I want to put my app and the libraries together in a PC, not to set up them separately and then tune them separately to make the program work there. Might there a way to release it as an app with all the libraries connected to it?
I feel it must be easy but I'm not so experienced. I'm sorry for that.
It is recommended that you use ClickOnce deployment:
ClickOnce deployment is a Microsoft technology that allows you to easily deploy your Windows Forms App along with all its dependencies. With ClickOnce deployment, you can publish your application to a web server or a file share and users can install it by simply clicking on a link. ClickOnce will automatically download and install all the required DLLs and packages on the user's computer.
Of course, there are some third-party packaging software that I can't recommend. If ClickOnce doesn't help you, I'll think of other ways.

How to run a setup file from Sharepoint using C#

I have two VS projects. One is to install something, the other project is an installer, basically a nice neat installer with pictures that calls the first project at the end to run the setup.exe.
Now, I want to publish this so that, someone can, on their computer, not mine, they can open my folder, open the setup file and it'll install fine, without errors like my setup.exe file being on my machine and not theirs.
Is there a way in Visual Studio where I can include that setup.exe file in my resources folder or what?
I was also thinking, when you say publish, there is a server option? I just have no idea how that works. We have a sharepoint website where we keep all our information.
Please and thank you.
Have you considered bundling your executables (installer and application) in to a ZIP file and having that downloadable? It wont launch automatically but it is a neater and preferred approach (from a security standpoint). If you have a thick client application, have you considered ClickOnce as a better option for deployment?
For neater and more secure options, look at the deploying section in here for best practice.
For your set up, you need two actions:
1) Download the setup file, use WebClient.DownloadFile and store it locally.
Alternatively, include it in the project and set the copylocal attribute so that it is part of the deployed binaries. Alternatively, this post tells you how to add it to the resource.
2) Use Process.Start("{Path to your downloaded setup.exe}") to launch the set up from your installer.

MSI installer automatically starting after application already installed when using "Everyone" option?

I have an application that was created using Visual Studio which contains an installation project. When I run the MSI that is built, 3 Windows Services are created. Everything installs fine, the services are there and I can start them, when I choose the option to install for "Just Me".
When I choose the option to install for "Everyone", all users on this machine, the services are still installed fine and I can start them while I am logged in as the same user who installed them BUT when I log in as a different user and try starting the application using a shortcut, the installer starts up and tries to uninstall the services. Weird thing is that it only uninstalls 2 of the 3 services.
Again, if I install using "Just Me" I am having no issues at all, it seems to be linked to the "Everyone" option. I am not sure how to even begin looking into this as I am new to setup projects (this project was created by someone else) so any help would be great.
I'm thinking in one of the installation folders a file must be missing for the second user and that is why the installation folder opens up again?
Thanks for any help.
SOLUTION:
The issue was with the DISABLEADVTSHORTCUTS property of the MSI because the shortcut that was installed for everyone was an Advertised Shortcut as far as I understand. There are a few ways to get around this using a post build event or using ORCA...we ended up using ORCA and adding the DISABLEADVTSHORTCUTS = 1 property to the MSI.
Solution and better explanation:
https://jcrawfor74.wordpress.com/2011/08/17/setup-app-config-during-msi-install-msi-re-installing/
https://support.microsoft.com/en-us/kb/255905
Try to find the called schema.msi under
C:\Program Files (x86)\Microsoft Visual Studio
This prototype is used in the consecutive generation of your deployment msi file. Then, you can use orca to add DISABLEADVTSHORTCUTS=1 to the Property table. So, from then on, all of your msi files will create the standard shortcut.

Install Shield msi file installing to the wrong directory (error 1309)

I am using Visual Studio 2013/ISLE to create a C# program with a .msi install image. When I run install from VS the program is installed in the expected location, e.g. c:/Program Files (x86)/...
I'm sure that this is something simple but I can't figure it out. A pointers would be greatly appreciated.
When you run a 32-bit installer in x 64-bit system Windows will always redirect your installer writing to c:\Program Files to c:\program files (x86). If you want to install to the non-x86 folder you will need to provide a 64-bit installer for your application.
This blog post explains why Windows does this.
It looks like InstallShield LE will allow you to write to the correct folder when your project is set to AnyCPU, but for more advanced scenario's you'll need to use the Pro version or the free Wix installer.
I assume the question is why the installation MSI fails when you run it outside of Visual Studio, but works when VS launches it?
If yes, you should first check if your ISLE project is creating an MSI or an EXE bootstrapper (that also contains the MSI). If an EXE is created this is what you should launch manually, not the MSI. In theory, a bootstrapper can act like an initialization support for the MSI and specify default values for certain properties, like an installation folder, etc...
I say in theory because I am not very familiar with ISLE, I work with other setup authoring tools, thus cannot say for sure if this stands for ISE projects too.

how to use VS Setup and Deployment project and build an .msi file to install the program?

i wanna deploy a C# Windows Application project using Setup and deployment project technique
but i don know what should i use
after i open File > New > Project > Setup and deployment > ....
then what ,, what should i do next
In the past I've used the Visual Studio Setup Project or Innosetup for my programs. I prefer to build .msi's over exe's so Visual Studio Setup Project has been my goto for a while now. It is however, very lacking in capabilities. The interface is not intuitive either in my opinion. Every time I build an installer there is a lot of trial and error install/uninstall to get it right. Other's have pointed out WIX and I've looked into it. It appears to be very flexible and since it is open source, we should be able to count on it for the long term.
Here is a recent article about WIX. What I found interesting is the article claims (see link in article) that Visual Studio Setup Project is being End Of Life'd in VS 2010 + NEXT_VERSION. This is a little disconcerting to me. Since I don't want to begin to rely on the new Install Shield "Lite" in VS, I'm going to put effort into learning WIX. I hope it'll pay off in more flexible builds for my applications as well.
All that said, when creating a VS Setup project, I usually use the wizard to put in the initial plumbing. You'll point it at the files you want in the .msi. Typically for me this means the "outputs" of one or more programs in my solution. Any managed assemblies referenced in the programs will automatically get picked up as dependencies and included. Unfortunately unmanaged assemblies don't and I usually have to add them manually using the "File System Editor" mode in the Setup Project UI. Adding shortcuts is a little hokey as well. You right click under the start menu and desktop section of the "File System Editor" mode and select create shortcut. This is all by memory so hopefully I'm getting this right. You will certainly have to test your installer multiple times before you get it just how you want. I like to test under a VM as well.
Finally, the VS Setup project produces a setup.exe and .msi file. Setup.exe is used for detecting and installing dependencies (such as .Net) before unpacking the actual DLL.
When u do this File > New > Project > Setup and deployment >
then right click Application folder> Add > File...and add your app's .exe file and also you can add shortcuts of your app in desktop and program's menu
I would recommend you to go for some tool for creating msi.
I am using WIX
What you need depends on... what you need.
For a large percentage of applications, all you need the installer to do is let the user choose an install location, copy files to a directory structure at that location, and create a few shortcuts. For that, a Visual Studio Installer -> Setup Project is fine. It can handle this basic functionality, as well as installing prerequisites like the .Net Framework redistributables, providing custom install options, and/or writing simple registry keys. The Setup Wizard creates a Setup Project as well, but runs you through a wizard to set up the basics. This is a good option if you've never created an installer before.
If you want this application to be controlled by a larger, more custom install, choose the CAB Project; it will simply pack the necessary files into an archive that is easily accessible from another setup project.
If you are publishing a class library, use a Merge Module. Merge Modules work within install programs themselves, providing files needed for the main application to work.
If you need serious customization, or you want to interface with existing InstallShield logic, I'd get a third-party installer. I've worked with InstallShield before, and it's pretty full-featured, but by the same token, the installers it creates are applications in their own right and can take days or weeks of logic programming to "tweak" to your satisfaction.

Categories

Resources