饭饭TXT > 学习管理 > 《Visual Studio 2010 高级编程(英文出书版)》作者:Nick Randolph/等【完结】 > [Visual.Studio.2010.高级编程].Professional.Visual.Studio.2010.txt

第 144 页

作者:Nick Randolph/等 当前章节:15455 字 更新时间:2026-6-18 14:51

that is to be made to the original configuration file. Locator, on the other hand, is used to identify

particular nodes to apply a transformation to. Here a few examples, along with a description of

what they do. For more information, see the full reference in the MSDN Library.

<appSettings>

<add xdt:Transform="Remove"xdt:Locator="Condition(@name=’UseMockDatabase’)"/>

</appSettings>

This locates an add node under appSettings with the name attribute set to UseMockDatabase and

removes it from the output configuration file.

<connectionStrings>

<add name="AdventureWorks" xdt:Transform="Replace" xdt:Locator="Match(name)"

connectionString="Data Source=UAT_DB; Initial Catalog=AdventureWorks; ~CA

Integrated Security=true"/>

</connectionStrings>

This updates the contents the AdventureWorks connection string to point to a UAT database server.

<system.web>

<compilation xdt:Transform="RemoveAttributes(debug)" />

</system.web>

This removes the debug attribute from the compilation node under system.web.

<authorization>

<deny users="*" xdt:Transform="Insert"/>

</authorization>

This inserts a new node at the bottom of the authorization element that denies access to all users.

Web Project installers .

991

web ProJect installers

In addition to using the Web Deployment Tool, you can create a standard Windows Installer package

to manage a web application or web site deployment. To do this, you will need to create a Web Setup

Project from the Other Project Types Setup and Deployment node in the New Project dialog. This is

essentially a normal setup project that has been configured with the relevant output folder (see the File

System view) and user interface (see the User Interface view) for deploying web applications. Once

you have created the setup project, you will need to add the appropriate project outputs. The left

image of Figure 49-9 shows the Add Project Output Group dialog for adding a web site to the setup

project. Because a web site contains only content files, this is the only option available.

Alternatively, when you are using a Web Application Project, you will want to select the primary

output as well as the content files, as shown in the right image of Figure 49-9.

fiGure 49-9

One of the unique features of the Web Setup

Project is the screen that is added to the user

interface to enable the user to define the web site,

virtual directory, and application pool that will

be used by the web application being installed.

Figure 49-10 illustrates this dialog as part of the

installation process.

In older versions of Visual Studio, the web site

installation wizard would only prompt the user

to specify the name of the virtual directory

into which the application was to be installed,

and this directory would then be created in

the default web site. If multiple web sites were

hosted on the same server (often the case with

products such as SharePoint installed), this

fiGure 49-10

992 .

chaPter 49 Web ApplicATion deploymenT

could result in the application being installed on the wrong web site. Being able to specify the

web site during installation reduces any post-installation administration that would have been

required in the past.

the web PlatforM installer

Web applications tend to rely on a large number of technologies and tools to function correctly

both during development and in production. Even once your environment is correctly set

up for a single application, relationships and dependencies between applications need to be

understood and managed. Finally, there are always new tools, libraries, and applications being

made available on the Internet, which you can build on when creating your own projects. As

your environment becomes more complex it can be quite a challenge to keep everything working

correctly and up to date.

The Microsoft Web Platform Installer, shown in Figure 49-11, is a simple tool designed to

manage the software that you have installed on your web servers and development machine.

fiGure 49-11

Once you have downloaded the Web Platform Installer from http://www.microsoft.com/web,

you can run it as many times as you like. It is able to detect which components you already

have on your machine and you can check and uncheck components to add and remove them,

The Web Platform installer .

993

respectively. It is even able to take care of dependencies between components and install everything

you need.

The Web Platform Installer is able to manage components beyond just the Web Platform itself.

Also available is a collection of applications from the Microsoft Web Application Gallery found at

http://www.microsoft.com/web/gallery. These applications are filed under various categories

under the Web Applications tab. Just like the components in the Web Platform, these applications

can have their own prerequisites and the Web Platform Installer takes care of ensuring they are

installed.

If you are already packaging your web application for deployment with MSDeploy, it is ready to

be distributed using the Web Platform Installer. You can get your application added to the Web

Application Gallery by filling in a simple form on the Microsoft Web portal. Once your application

is approved, it will show up ready to be installed on any machine with the Web Platform Installer

on it.

extending the web Platform installer

As mentioned in the previous section, it is quite easy to have your application included in the Web

Application Gallery to make it available to a large audience. There are some scenarios in which

you would like to take advantage of the Web Platform Installer but do not want to make your

application publicly available. This might be because your application is being used privately within

your company or it might be because your application is not yet ready for release and you want to

test the deployment procedure.

The Web Platform Installer relies on atom feeds to ensure that the list of components and products

that it installs are always kept up to date. Each entry in these feeds corresponds to an application

or component in the user interface of the Web Platform Installer. The Web Platform and Web

Application tabs each come from different feeds at http://www.microsoft.com/web/webpi/2.0/

WebProductList.xml and http://www.microsoft.com/web/webpi/2.0/WebApplicationList

.xml, respectively. In addition to these two feeds, each installation of the Web Platform Installer can

specify additional feeds that reference more components.

Here is a sample feed for a simple timesheets web application:

<?xml version=”1.0” encoding=”utf-8”?>

<feed xmlns=”http://www.w3.org/2005/Atom”>

<version>1.0.0</version>

<title>AdventureWorks Product WebPI Feed</title>

<link href=”http://www.professionalvisualstudio.com/SampleProductFeed.xml” />

<updated>2009-11-01T16:30:00Z</updated>

<author>

<name>Adventure Works</name>

<uri>http://www.professionalvisualstudio.com</uri>

</author>

<id>http://www.professionalvisualstudio.com/SampleProductFeed.xml</id>

<entry>

994 .

chaPter 49 Web ApplicATion deploymenT

<productId>TimeSheets</productId>

<title>Adventure Works Timesheets</title>

<summary>The Adventure Works corporate Timesheeting system</summary>

<longSummary>The Adventure Works corporate Timesheeting system</longSummary>

<productFamily>Human Resources</productFamily>

<version>1.0.0</version>

<images>

<icon>c:\AdventureWorksIcon.png</icon>

</images>

<author>

<name>Adventure Works IT</name>

<uri>http://www.professionalvisualstudio.com</uri>

</author>

<published>2009-11-01T12:30:00Z</published>

<discoveryHint>

<or>

<discoveryHint>

<registry>

<keyPath>HKEY_LOCAL_MACHINE\SOFTWARE\AdventureWorks\Timesheets</keyPath>

<valueName>Version</valueName>

<valueValue>1.0.0</valueValue>

</registry>

</discoveryHint>

<discoveryHint>

<file>

<filePath>%ProgramFiles%\AdventureWorks\Timesheets.exe</filePath>

</file>

</discoveryHint>

</or>

</discoveryHint>

<dependency>

<productId>IISManagementConsole</productId>

</dependency>

<installers>

<installer>

<id>1</id>

<languageId>en</languageId>

<architectures>

<x86 />

</architectures>

<osList>

<os>

<!-- the product is supported on Vista/Windows Server SP1 + -->

<minimumVersion>

<osMajorVersion>6</osMajorVersion>

<osMinorVersion>0</osMinorVersion>

<spMajorVersion>0</spMajorVersion>

</minimumVersion>

<osTypes>

The Web Platform installer .

995

<Server />

<HomePremium />

<Ultimate />

<Enterprise />

<Business />

</osTypes>

</os>

</osList>

<eulaURL>http://www.professionalvisualstudio.com/eula.html</eulaURL>

<installerFile>

<!-- size in KBs -->

<fileSize>1024</fileSize>

<installerURL>http://www.professionalvisualstudio.com/Timesheets_x86.msi

</installerURL>

<sha1>111222FFF000BBB444555EEEAAA777888999DDDD</sha1>

</installerFile>

<installCommands>

<msiInstall>

<msi>%InstallerFile%</msi>

</msiInstall>

</installCommands>

</installer>

</installers>

</entry>

<tabs>

<tab>

<groupTab>

<id>AdventureWorksHRTab</id>

<name>Adventure Works Human Resources</name>

<description>Adventure Works HR Apps</description>

<groupingId>HRProductFamilyGrouping</groupingId>

</groupTab>

</tab>

</tabs>

<groupings>

<grouping>

<id>HRProductFamilyGrouping</id>

<attribute>productFamily</attribute>

<include>

<item>Human Resources</item>

</include>

</grouping>

</groupings>

</feed>

The first part specifies some standard information about the feed itself, including the date it was

last updated and author information. This is all useful if the feed is consumed using a normal feed

reader. Following this is a single entry node containing information about the application itself.

The Web Platform Installer is able to use the value of productId to refer to the application in other

places, including being listed as a dependency for other components.

996 .

chaPter 49 Web ApplicATion deploymenT

The discoveryHint node is used to determine if this application is already installed. The

sample application can be detected by looking for a specific registry key value or by looking for

a specific application by name. If either one of these items is found, the Web Platform Installer

considers this application to be already installed. In addition to these two kinds of hints, you can

use an msiProductCode hint to detect applications that are installed via MSI.

The sample timesheets application has a dependency on the IIS Management Console. Each

component that your application relies upon can be specified by its productId. If it is not already

installed on the target machine, the Web Platform Installer will install it for you. In addition to

dependencies, you can specify incompatibilities for your application, which will prevent both

applications from being installed at once.

The last component of the application entry is the installers element. There should be one

installer element for each installer that you want to make available and they should all have

different identifiers. Each installer can be targeted at a specific range of languages, operating

systems, and CPU architectures. If the target environment doesn’t fall into this range, the installer

will not be shown. Each installer should specify an installer file, which will be downloaded to a

local cache before the specified installCommands are executed against it.

An installer file requires a size and a SHA1 hash so that the Web Platform

Installer can verify that the file has been downloaded correctly. Microsoft

provides a tool called File Checksum Integrity Verifier (fciv.exe), which can be

used to generate the hash. You can download this tool from http://download.microsoft.com.

The final two elements relate to what is displayed in the Web Platform Installer user interface.

Each tab element adds to the list of tabs on the left. In the example, we are adding a tab based

on a grouping of products, which is defined below in the groupings element based on the

productFamily attribute.

To add this feed to a Web Platform Installer instance, click the Options link in the lower left-hand

corner to bring up the Options page. Enter the URL to the atom feed into the textbox and click

the Add Feed button. When you click OK the Web Platform Installer refreshes all of the feeds and

reloads all of the applications including the new Adventure Works timesheets application shown in

Figure 49 - 12.

summary .

997

fiGure 49-12

suMMary

This chapter showed you how to use a number of the features of Visual Studio 2010 to package

your web applications and get them ready for deployment. The new Web Deployment Tool makes

deployment to a number of environments and machines quick and painless, and the One Click

Publish toolbar makes it easy to manage the different publishing profiles. Finally, the Web Platform

目录
设置
设置
阅读主题
字体风格
雅黑 宋体 楷书 卡通
字体大小
适中 偏大 超大
保存设置
恢复默认
手机
手机阅读
扫码获取链接,使用浏览器打开
书架同步,随时随地,手机阅读
首 页 < 上一章 章节列表 下一章 > 尾 页