64
Create Installation Packages in Visual Studio Hans-Petter Halvorsen, M.Sc. Step by step Exercises

Deployment in Visual Studio - Telemark Universityhome.hit.no/~hansha/documents/software/software_development/topic… · Setup & Deployment in Visual Studio • InstallShield Limited

  • Upload
    lamminh

  • View
    227

  • Download
    2

Embed Size (px)

Citation preview

CreateInstallationPackagesinVisualStudio

Hans-PetterHalvorsen,M.Sc.

StepbystepExercises

Development Testing Production

DevelopmentEnvironment TestEnvironment

ProductionEnvironment

TypicallytheDevelopersPersonalComputerwithDatabase,WebServerandProgrammingSoftware

ACleanPC/Server(oranetworkwithPCsandServers)whereyouinstallandtestyourSoftware.Todaywetypicallyset-upaVirtualTestEnvironment

TheCustomersenvironmentwhereyouunstall thefinalsoftware(ServersandClients)

Programming environments suchasVisualStudio,etc.shouldnotbeinstalledinthisenvironment.Youneedtocreate.exefilesetc.inordertomakeyoursoftwarerun.

Developers Developers&Testers Customers

Deployment&Installation

Maintenance

Support

Test/ProductionEnvironmentInfrastructurewithServers,VirtualServers,DatabaseServers,WebServers,etc.

• LocalInfrastructurewithServers&Virtualization• Cloud-basedInfrastructure(monthlypayment),e.g.:–WindowsAzure(VisualStudiohasbuilt-insupportforDeployingtoWindowsAzure)

– AmazonWebServices(AWS)– GoogleCloudPlatform– etc. 3

DeploymentIsitaGenericSoftwareProductoraTailor-madeSoftwareSolution?

– DifferentDeployment/Installationpreparationsrequired!!• GenericSoftware:

• ManyCustomers• TheCustomersinstall theSoftwareitself

• Tailor-made:– TypicallyonlyoneCustomer– TheDeveloperCompanytypicallyinstallsthesoftware(atleast

server-sidecomponents)– IfmanyDesktopClients:ASetupisrequired

4

Setup&DeploymentDesktopApps

• Youneed tocreatean.exefileandaSetupPackage• SetuppackagescanthenbedistributedonCDs/DVDsordownloaded fromaWebPage,etc.• YouusetheSetupinordertoinstallthesoftwareonalltheclients• Timeconsuming,cumbersome,dependsonlocalcomponentsthatmightnotbeinstalled,versionconflicts,etc.Thismakesit

difficult(andalotofworkandtesting)tocreaterobustsetuppackages• Mac:Youcandeploy toMacAppStore,Windows10:Youcandeploy toWindowsStore

WebApps• Noclient installationneeded!• InstalledonaWebServer(IIS,Apache)• AccessedontheClientsusingonlyaWebBrowser• Easy,simpletodeploynewversions,bugfixes,etc.(Customerdont needtodoanything)• ButmakesureyouAppsupportsallmajorWebBrowsers(InternetExplorer,Chrome,FireFox,Opera,Safari)

MobileApps• Deployed to"AppStores"likeAppleAppStore,GooglePlay,WindowsStore(Windows8)

Server-side(Database,Web Services, etc.)• Typicallyasetuppackagethatinstallsthis,ormanuallyifitisatailor-madesolution

5

DifferentDeployment/Installationpreparations requireddepending onwhattypeofAppsyouareDeveloping.

SetupCreationSoftware• InstallShield Professional/Premium

– InstallShieldisaprofessional softwareforcreatinginstallers,Price€2000+• WiX Toolset (WindowsInstallerXML)(Free)

– UsedtocreateWindowsInstallerpackages("MSIfiles)– TheWiXtoolsetbuildsWindowsinstallationpackagesfromXMLsourcecode.– FreeandOpenSource– Usedbye.g.,Microsoft tocreateSetuppackagesforOffice,SQLServer,Visual

Studio,etc.Apple,etc.alsouseit.• InnoSetup

– FreeofchargeInstallerforWindowsprograms• NSIS (NullsoftScriptableInstallSystem)

– ProfessionalopensourcesystemtocreateWindows installers.• etc.

6

Setup&DeploymentinVisualStudio• InstallShieldLimitedEdition(InstallShieldProfessionalisaprofessional softwarefor

creatinginstallers,Price€2000+)– Toolforcreatingsetuppackages– "Included"(free),butneedstobeenabledanddownloaded– IntegrateswithVisualStudio(Prof.edcanbeusedindependently)

• WiXToolset (Windows InstallerXML)– UsedtocreateWindowsInstallerpackages("MSIfiles)– CanbeusedinVisualStudioorindependently

• ClickOnceDeployment.PublishingDesktopAppstoaWebServer.Userscantheninstallthemwithasingleclick.

• Deployment toWindowsAzure("Windows intheCloud").MonthlyPayment• WebApps(WebDeploy)

– Createa“WebDeploymentPackage”whichcanbeimportedusingIIS• MobileApps:WindowsStoreApps

– Built-inDeploymentinsideVisualStudiotoWindowsStore

7

Setup&DeploymentinVisualStudio

8

http://msdn.microsoft.com/en-us/library/wtzawcsz.aspxDeployingApplications,Services,andComponents:

4ExercisesA.CreateSetupPackages/Installers:Canbeusedtoinstallallkindofsoftware/components

1. InstallShieldLE(LimitedEdition)2. WiX

B.DeployWebSitesonIIS:3. WebPackageDeployment

C.WinFormorWPFApps:4. ClickOnceDeployment

9

Hans-PetterHalvorsen,M.Sc.

InstallShieldLELimitedEdition forVisualStudio

1

CreateaWinFormApp

11

ThisistheAppthatshallbeinstalledfromaSetup

CreateaWinFormApp

12

ThisistheAppthatshallbeinstalledfromaSetup

Thisisjustanexample– createwhateveryoulike

BuildyourAppandmakesureitworks!

InstallShieldLimitedEditionToenable InstallShieldLimitedEdition:1. Onthemenubar,chooseFile,New,Project.2. IntheNewProjectdialogbox,expandtheOther

ProjectTypesnode,andthenchoosetheSetupandDeploymentnode.

3. Inthetemplatelist,chooseEnableInstallShieldLimitedEdition,andthenchoosetheOKbutton.

4. Inthebrowserwindowthatopens,readtheinstructions,andthenchoosetheGotothedownloadwebsitelink.

13

forVisualStudio

Seenextslideforscreenshot...

InstallShieldLimitedEdition

14

forVisualStudio

Installation

InstallShieldLimitedEdition

15

forVisualStudioStartCreatingyourSetup

SelectaproperName

InstallShieldLimitedEdition

16

forVisualStudio

InstallShieldLimitedEdition

17

forVisualStudio

Step1:ApplicationInformation

InstallShieldLimitedEdition

18

forVisualStudio

Step2:InstallationRequirements

InstallShieldLimitedEdition

19

forVisualStudio

Step3:ApplicationFiles

Selectyour.ExeFile

InstallShieldLimitedEdition

20

forVisualStudio

Step4:ApplicationShortcuts

InstallShieldLimitedEdition

21

forVisualStudio

etc.,GothroughallthestepsintheWizard

Finally:• BuildtheSetupProject• TestyouSetup(preferablyonaVirtual

Machineoraseparatetestcomputer(why?))

InstallShieldLimitedEdition

22

forVisualStudio

ThisisyourSetupFiles/SetupPackage

CopytheSetupPackagetotheComputerwhereyouwanttotestitandRun“Setup.exe”

InstallShieldLimitedEdition

23

forVisualStudio

YourFinalSetup

InstallShieldLimitedEdition

24

forVisualStudio

25YouarefinishedwiththeExercise

Hans-PetterHalvorsen,M.Sc.

WindowsInstallerXMLWiXToolset

2

DownloadWiXToolset

27

http://wixtoolset.org

WiXDocumentation

• WiXManual:http://wixtoolset.org/documentation/manual/v3/• WiXTutorial:http://wix.tramontana.co.hu

28

WiXExample

http://wixtoolset.org/documentation/manual/v3/votive/authoring_first_votive_project.html

Inthisexample,wewillcreateaC#WindowsFormApplicationandthenuseWiXtocreateaninstallerfortheapplication.

Step1:CreatetheC#WindowsFormApplication• ClickFile, thenselectNew,thenselectProject.• Choose theVisualC#node intheProjectTypes tree,thenselectWindows FormsApplication.• Nameyourapplicatione.g.,"MyApplication”(Usewhateveryouwant)andpressOK.Step2:CreatetheInstallerfortheapplication• ClickFile, thenclickNew,thenclickProject.• Choose theWindows InstallerXMLnodeintheProjecttypestree,thenselectWiXProject• Nameyourproject"MySetup"andpressOK.• IntheMySetupproject,right-clickontheReferencesnodeandchooseAddReference....• NavigatetotheProjectstab,clickontheMyApplicationproject,andclicktheAddbutton,andthenpressOK.• Find thecommentthatsays:

<!-- TODO:Insertyourfiles, registrykeys,andotherresourceshere.-->Deletethatlineandreplaceitwiththefollowinglines ofcode:<FileSource="$(var.MyApplication.TargetPath)"/>

• BuildtheWixproject

CreateaWinFormApp

30

ThisistheAppthatshallbeinstalledfromaSetup

CreateaWinFormApp

31

ThisistheAppthatshallbeinstalledfromaSetup

Thisisjustanexample– createwhateveryoulike

CreateWiXSetupProject

32

33

InstallerXMLCode

<?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><Directory Id="TARGETDIR" Name="SourceDir"><Directory Id="ProgramFilesFolder"><Directory Id="INSTALLFOLDER" Name="MySetup" /></Directory></Directory>

</Fragment>

<Fragment>

<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">

<Component Id="ProductComponent"> <File Source="$(var.WinFormApp.TargetPath)" />

</Component>

</ComponentGroup>

</Fragment></Wix>

TheInstaller/SetupisReady

35

RuntheInstaller(“MySetup.msi”) inordertoinstallyourSoftware

Note!ThisSetuphasnoGUI– itjustinstallsyoursoftware(moreadvancedsetupscanofcoursebecreated)

36

Asyouseeithasbeenproperly installed

AfterInstallation

Double-clicktoopenyourApp

37YoumayUninstallitifyouwant

Uninstallation

38

That'sit!Nowyouhaveaworkinginstallerthatinstallsanduninstallstheapplication.ThiswasaverysimpleInstallerwithnoWizardorinteractionwiththeuserduringInstallation.

WithWixyoucandoallthisandmore.

FormoreinformationaboutWiX,setheonlinedocumentation.

WiXManual:http://wixtoolset.org/documentation/manual/v3/WiXTutorial:http://wix.tramontana.co.hu

39

ExamplewithUserInterface

40

ExamplewithUserInterface

41YouarefinishedwiththeExercise

Hans-PetterHalvorsen,M.Sc.

WebPackageDeployment

http://www.iis.net/downloads/microsoft/web-deploy

3

WebDeploymentAlternatives:- Createa“InstallationPackage”thatyouortheCustomerneedtoinstallontheserver(WebDeployPackage)

- Deploydirectlytotheserverusing“WebDeploy”(Youneedtohaveonlineaccesstotheserver)

- Deploydirectlytotheserverusing“FTP”(Youneedtohaveonlineaccesstotheserver)

- ...

43

44

OntheDevelopmentComputer

WebPackageDeployment

45

Note!InordertostartonthisExercise,youneedtocreateanASP.NETprojectoruseanexistingASP.NETProject.

Right-clickon theASP.NETProjectintheSolution ExplorerinVisualStudioandselect“Publish...”

Ifyoumissthe“Deploy”option,makesuretoinstallthe“WebDeploy”features.YoumaydownloadandinstallitfromWebPI(WebPlatformInstaller)(Googleitanddownloadit)

46

CreateWebPackageWizard

47

CreateWebPackageWizard

48

IfyourWebAppusesaDatabaseconnectioninWeb.config, youmaysetuptheConnectionStringontheServerhere.

xxx

49

OntheTestorProductionServer

PreparationYouneedtoinstallthe“WebDeploy”softwareontheServerDownloadWebPI(WebPlatformInstaller)andthenselecttoInstall“WebDeployforHostingServers”

50

ImportPackageinIIS

51

ImportPackageinIIS

52

Makesureyouhavecopied theInstallationPackagetotheServer

WebPackageDeployment

53

TestIt

54

IfyourWebAppusesaDatabase,youneedtosetup/configure thedatabase.

55YouarefinishedwiththeExercise

Hans-PetterHalvorsen,M.Sc.

ClickOnceDeploymentEasyDeploymentofWinFormAppsandWPFApps

4

ClickOnceDeploymentEasyDeploymentofWinFormAppsandWPFApps

ClickOnceDeployment• ClickOnceisadeploymenttechnologythatenablesyouto

createself-updatingWindows-basedapplicationsthatcanbeinstalledandrunwithminimaluserinteraction.

• AClickOnceapplicationisanyWindowsPresentationFoundation(.xbap),WindowsForms(.exe),consoleapplication(.exe),orOfficesolution(.dll)publishedusingClickOncetechnology.

• Youcanpublisha ClickOnceapplicationinthreedifferentways:– fromaWebpage– fromanetworkfileshare– frommediasuchasaCD-ROM.

58

59

Right-clickonyourWinFormorWPFProjectintheSolutionExplorer

SelectwhereyouwanttostoretheInstaller.

ThenyoucandistributethelinktotheUsersthatneedtoinstalltheapplication

60

61

TheInstallationPacckagewascreated:

CopytheInstallationPakagetotheServer

GivethelinktotheUsersthatshalltoInstallandusetheSoftware

62

GivethelinktotheUsersthatshalltoInstallandusetheSoftware

63YouarefinishedwiththeExercise

Hans-PetterHalvorsen,M.Sc.

UniversityCollegeofSoutheastNorwaywww.usn.no

E-mail:[email protected]:http://home.hit.no/~hansha/