Create Installa+on Packages in Visual Studio Step by step Exercises Hans- Pe8er Halvorsen, M.Sc.
Maintenance Developers Developers & Testers Customers Development Tes+ng Produc+on Deployment & Installa+on Support A Clean PC/Server (or a network The Customers with PCs and Servers) where you environment where you install and test your SoHware. unstall the final sohware Today we typically set- up a Virtual Test Environment Typically the Developers Personal Computer with Database, Web Server and Programming SoHware Development Environment Test Environment (Servers and Clients) Produc+on Environment Programming environments such as Visual Studio, etc. should not be installed in this environment. You need to create.exe files etc. in order to make your sohware run.
Test/Produc+on Environment Infrastructure with Servers, Virtual Servers, Database Servers, Web Servers, etc. Local Infrastructure with Servers & Virtualiza+on Cloud- based Infrastructure (monthly payment), e.g.: Windows Azure (Visual Studio has built- in support for Deploying to Windows Azure) Amazon Web Services (AWS) Google Cloud PlaTorm etc. 3
Deployment Is it a Generic SoHware Product or a Tailor- made SoHware Solu+on? Different Deployment/Installa+on prepara+ons required!! Generic SoHware: Many Customers The Customers install the SoHware itself Tailor- made: Typically only one Customer The Developer Company typically installs the sohware (at least server- side components) If many Desktop Clients: A Setup is required 4
Setup & Deployment Desktop Apps You need to create an.exe file and a Setup Package Different Deployment/Installa+on prepara+ons required depending on what type of Apps you are Developing. Setup packages can then be distributed on CDs/DVDs or downloaded from a Web Page You are use the Setup in order to install the sohware on all the clients Time consuming, combersome, depends on local components that might not be installed, version conflicts, etc. This makes it difficult (and a lot of work and tes+ng) to create robust setup packages Mac: You can deploy to Mac App Store, Windows 8: You can deploy to Windows Store Web Apps No client installa+on needed! Installed on a Web Server (IIS, Apache) Accessed on the Clients using only a Web Browser Easy, simple to deploy new versions, bugfixes, etc. (Customer dont need to do anything) But make sure you App supports all major Web Browsers (Internet Explorer, Chrome, FireFox, Opera, Safari) Mobile Apps Deployed to "App Stores" like Apple App Store, Google Play, Windows Store (Windows 8) Server- side (Database, Web Services, etc.) Typically a setup package that installs this, or manually if it is a tailor- made solu+on 5
Setup Crea+on SoHware InstallShield Professional/Premium InstallShield is a professional sohware for crea+ng installers, Price 2000+ WiX Toolset (Windows Installer XML) (Free) Used to create Windows Installer packages ("MSI files) The WiX toolset builds Windows installa+on packages from XML source code. Free and Open Source Used by e.g., MicrosoH to create Setup packages for Office, SQL Server, Visual Studio, etc. Apple, etc. also use it. Inno Setup Free of charge Installer for Windows programs NSIS (NullsoH Scriptable Install System) Professional open source system to create Windows installers. etc. 6
Setup & Deployment in Visual Studio InstallShield Limited EdiMon (InstallShield Professional is a professional sohware for crea+ng installers, Price 2000+) Tool for crea+ng setup packages "Included" (free), but needs to be enabled and downloaded Integrates with Visual Studio (Prof. ed can be used independently) WiX Toolset (Windows Installer XML) Used to create Windows Installer packages ("MSI files) Can be used in Visual Studio or independently ClickOnce Deployment. Publishing Desktop Apps to a Web Server. Users can then install them with a single click. Deployment to Windows Azure ("Windows in the Cloud"). Monthly Payment Web Apps (Web Deploy) Create a Web Deployment Package which can be imported using IIS Mobile Apps: Windows Store Apps Built- in Deployment inside Visual Studio to Windows Store 7
Setup & Deployment in Visual Studio Deploying Applica+ons, Services, and Components: h8p://msdn.microsoh.com/en- us/library/wtzawcsz.aspx 8
4 Exercises A. Create Setup Packages/Installers: Can be used to install all kind of sohware/components 1. InstallShield LE (Limited EdiMon) 2. WiX B. Deploy Web Sites on IIS: 3. Web Package Deployment C. WinForm or WPF Apps: 4. ClickOnce Deployment 9
1 InstallShield LE Limited Edi+on for Visual Studio Hans- Pe8er Halvorsen, M.Sc.
Create a WinForm App This is the App that shall be installed from a Setup 11
Create a WinForm App This is the App that shall be installed from a Setup This is just an example create what ever you like Build your App and make sure it works! 12
InstallShield Limited Edi+on for Visual Studio To enable InstallShield Limited Edi+on: 1. On the menu bar, choose File, New, Project. 2. In the New Project dialog box, expand the Other Project Types node, and then choose the Setup and Deployment node. 3. In the template list, choose Enable InstallShield Limited Edi+on, and then choose the OK bu8on. 4. In the browser window that opens, read the instruc+ons, and then choose the Go to the download web site link. See next slide for screen shot... 13
InstallShield Limited Edi+on for Visual Studio Installa+on 14
InstallShield Limited Edi+on Start Crea+ng your Setup for Visual Studio Select a proper Name 15
InstallShield Limited Edi+on for Visual Studio 16
InstallShield Limited Edi+on Step 1: Applica+on Informa+on for Visual Studio 17
InstallShield Limited Edi+on Step 2: Installa+on Requirements for Visual Studio 18
InstallShield Limited Edi+on Step 3: Applica+on Files for Visual Studio Select your.exe File 19
InstallShield Limited Edi+on Step 4: Applica+on Shortcuts for Visual Studio 20
InstallShield Limited Edi+on for Visual Studio etc., Go through all the steps in the Wizard Finally: Build the Setup Project Test you Setup (preferably on a Virtual Machine or a separate test computer (why?)) 21
InstallShield Limited Edi+on for Visual Studio This is your Setup Files/Setup Package Copy the Setup Package to the Computer where you want to test it and Run Setup.exe 22
InstallShield Limited Edi+on Your Final Setup for Visual Studio 23
InstallShield Limited Edi+on for Visual Studio 24
You are finished with the Exercise 25
2 WiX Toolset Windows Installer XML Hans- Pe8er Halvorsen, M.Sc.
Download WiX Toolset h8p://wixtoolset.org 27
WiX Documenta+on WiX Manual: h8p://wixtoolset.org/documenta+on/manual/v3/ WiX Tutorial: h8p://wix.tramontana.co.hu 28
WiX Example In this example, we will create a C# Windows Form Applica+on and then use WiX to create an installer for the applica+on. Step 1: Create the C# Windows Form ApplicaMon Click File, then select New, then select Project. Choose the Visual C# node in the Project Types tree, then select Windows Forms Applica+on. Name your applica+on e.g., "MyApplica+on (Use whatever you want) and press OK. Step 2: Create the Installer for the applicamon Click File, then click New, then click Project. Choose the Windows Installer XML node in the Project types tree, then select WiX Project Name your project "MySetup" and press OK. In the MySetup project, right- click on the References node and choose Add Reference... Navigate to the Projects tab, click on the MyApplica+on project, and click the Add bu8on, and then press OK. Find the comment that says: <!- - TODO: Insert your files, registry keys, and other resources here. - - > Delete that line and replace it with the following lines of code: <File Source="$(var.MyApplica+on.TargetPath)" /> Build the Wix project h8p://wixtoolset.org/documenta+on/manual/v3/vo+ve/authoring_first_vo+ve_project.html
Create a WinForm App This is the App that shall be installed from a Setup 30
Create a WinForm App This is the App that shall be installed from a Setup This is just an example create what ever you like 31
Create WiX Setup Project 32
Installer XML Code 33
<?xml version="1.0" encoding="utf- 8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Product Id="*" Name="MySetup" Language="1033" Version="1.0.0.0" Manufacturer="Telemark University College" UpgradeCode="2ee9a35c- e8ba- 4197- a97f- 192b80a1d6bf"> <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /> <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> <MediaTemplate /> <Feature Id="ProductFeature" Title="MySetup" Level="1"> <ComponentGroupRef Id="ProductComponents" /> </Feature> </Product> <Fragment> </Fragment> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFilesFolder"> <Directory Id="INSTALLFOLDER" Name="MySetup" /> </Directory> </Directory> <Fragment> </ComponentGroup> </Fragment> </Wix> <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> <Component Id="ProductComponent"> <File Source="$(var.WinFormApp.TargetPath)" /> </Component>
The Installer/Setup is Ready Run the Installer ( MySetup.msi ) in order to install your SoHware Note! This Setup has no GUI it just installs your sohware (more advanced setups can of course be created) 35
AHer Installa+on As you see it has been properly installed Double- click to open your App 36
Uninstalla+on You may Uninstall it if you want 37
That's it! Now you have a working installer that installs and uninstalls the applica+on. This was a very simple Installer with no Wizard or interac+on with the user during Installa+on. With Wix you can do all this and more. For more informa+on about WiX, se the online documenta+on. WiX Manual: h8p://wixtoolset.org/documenta+on/manual/v3/ WiX Tutorial: h8p://wix.tramontana.co.hu 38
Example with User Interface 39
Example with User Interface 40
You are finished with the Exercise 41
3 Web Package Deployment h8p://www.iis.net/downloads/microsoh/web- deploy Hans- Pe8er Halvorsen, M.Sc.
Web Deployment Alterna+ves: - Create a Installa+on Package that you or the Customer need to install on the server (Web Deploy Package) - Deploy directly to the server using Web Deploy (You need to have online access to the server) - Deploy directly to the server using FTP (You need to have online access to the server) -... 43
On the Development Computer 44
Web Package Deployment Note! In order to start on this Exercise, you need to create an ASP.NET project or use an exis+ng ASP.NET Project. Right- click on the ASP.NET Project in the Solu+on Explorer in Visual Studio and select Publish... 45
If you miss the Deploy op+on, make sure to install the Web Deploy features. You may download and install it from WebPI (Web PlaTorm Installer) (Google it and download it) 46
Create Web Package Wizard 47
Create Web Package Wizard If your Web App uses a Database connec+on in Web.config, you may setup the Connec+on String on the Server here. xxx 48
On the Test or Produc+on Server 49
Prepara+on You need to install the Web Deploy sohware on the Server Download WebPI (Web PlaTorm Installer) and then select to Install Web Deploy for Hos+ng Servers 50
Import Package in IIS 51
Import Package in IIS Make sure you have copied the Installa+on Package to the Server 52
Web Package Deployment 53
Test It If your Web App uses a Database, you need to setup/configure the database. 54
You are finished with the Exercise 55
4 ClickOnce Deployment Easy Deployment of WinForm Apps and WPF Apps Hans- Pe8er Halvorsen, M.Sc.
ClickOnce Deployment Easy Deployment of WinForm Apps and WPF Apps
ClickOnce Deployment ClickOnce is a deployment technology that enables you to create self- upda+ng Windows- based applica+ons that can be installed and run with minimal user interac+on. A ClickOnce applica+on is any Windows Presenta+on Founda+on (.xbap), Windows Forms (.exe), console applica+on (.exe), or Office solu+on (.dll) published using ClickOnce technology. You can publish a ClickOnce applica+on in three different ways: from a Web page from a network file share from media such as a CD- ROM. 58
Right- click on your WinForm or WPF Project in the Solu+on Explorer Select where you want to store the Installer. Then you can distribute the link to the Users that need to install the applica+on 59
60
The Installa+on Pacckage was created: Copy the Installa+on Pakage to the Server Give the link to the Users that shall to Install and use the SoHware 61
Give the link to the Users that shall to Install and use the SoHware 62
You are finished with the Exercise 63
Hans- Pe`er Halvorsen, M.Sc. Telemark University College Faculty of Technology Department of Electrical Engineering, InformaMon Technology and CyberneMcs E- mail: hans.p.halvorsen@hit.no Blog: h`p://home.hit.no/~hansha/ 64