Вы находитесь на странице: 1из 9

-Open any Existing Project

-Create a new Setup Project ,

-Right Click on the Setup Project and Click View.


Figure 5: File System Editor

Click on the File System

The File System provides the essential tools to work with the application folder, user's
desktop, and the user's programs menu.

Figure 6: File System Editor

The first thing we want to do here is to include the relevant files and folders we wish to
install on the user's machine. This is accomplished by right clicking the Application
Folder and selecting 'Add'. The following screenshot is an example of something similar
you may see.
Figure 7: Add Project Output

Now to add project output files to this folder, Click Project Output.

Select the existing Project Name.

Merely add one or more of the files that is vital for your application by clicking on
File…. Now that you have you files in place.

Figure 8: Project Output


Prerequisites Installation in Windows Installer

Most applications have prerequisites: Components such as the .NET Framework runtime
must be available on a target computer in order for the application to run. The
deployment tools in Visual Studio include the capability to automatically detect the
existence of components during installation and install a predetermined set of
prerequisites — a process known as bootstrapping.

This will be achieved as follows:

To choose which prerequisites to install


In Solution Explorer, select the deployment project and Right Click
Click Properties.
In the Property Pages dialog box, expand the Configuration Properties node, and then
select the Build property page.
Click the Prerequisites button.
In the Prerequisites dialog box, make sure that the Create setup program to install
prerequisite components box is checked.
In the Choose which prerequisites to install list, check the prerequisites that you wish
to install, and then click OK.
To specify the download location for prerequisites
In Solution Explorer, select the deployment project, right click.
Click Properties.
In the Property Pages dialog box, expand the Configuration Properties node, and then
select the Build property page.
Click the Prerequisites button.

In the Prerequisites dialog box, choose a location:


If you want to deploy the installers for the prerequisites to a vendor, click Download
prerequisites from the component vendor's web site.
If you want to deploy the installers for the prerequisites to the same location as your
application installer, click Download prerequisites from the same location as my
application.
o If you want to deploy the installers for the prerequisites to a different
location, click Download prerequisites from the following location and
enter a local path, URL, or file-share location.

• Click OK to continue.
We need these prerequisites
-.Net FrameWork .02
-windows installer
-Crystall Reports for .Net FrameWork
-SQl Server 2005 Express Edition

Adding an Installer Class to the Existing Project

Add a new Installer Class to the project by clicking on Project, Add Class, select the Installer
Class template, you may enter any name, the name we will use in this procedure is
MyInstallerClass.
-Right Click on the Setup Project and Click View.

Figure 5: File System Editor

Click on the Custom Actions


-Right click on Install Folder and Click to Add Custom Action
-In the Dialg ,Choose an Application Folder ,then the Primary OutOut

in the Property Section

Add this Code to CustomActionData

/TargetDir="[TARGETDIR]\"

In the Installer class Override this Code

Public Overrides Sub Install(ByVal stateSaver As


System.Collections.IDictionary)
MyBase.Install(stateSaver)
Dim regsrv As New RegistrationServices
regsrv.RegisterAssembly(MyBase.GetType().Assembly,
AssemblyRegistrationFlags.SetCodeBase)
Try
' VB.NET Code

Dim TargetPath As String =


Me.Context.Parameters.Item("TargetDir")
Dim conn As New SqlConnection("Data
Source=.\SQLExpress;Integrated Security=true;")
'Private Shared objconnection As New SqlConnection("Data
Source=PC67\SQLEXPRESS;Initial Catalog=CV;Integrated Security=True")
Dim cmd As New SqlCommand("", conn)

cmd.CommandText = "exec sys.sp_attach_db Tasks,


@filename1='" & TargetPath & "Tasks.mdf' ," & _
" @filename2= '" & TargetPath &
"Tasks_log.ldf';"
conn.Open()

cmd.ExecuteNonQuery()

cmd.Dispose()
conn.Dispose()

Catch ex As Exception
MsgBox("xxxxx" & ex.Message)
End Try
End Sub

Adding SQL files

Right Click on the Setup Project and Click View.

Figure 5: File System Editor

Click on the File Types

Choose the mdf and ldf files….

Вам также может понравиться