-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.proj
More file actions
77 lines (63 loc) · 3.51 KB
/
deploy.proj
File metadata and controls
77 lines (63 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Deploy" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- common variables -->
<PropertyGroup>
<Machine Condition="'$(AppPoolName)' == ''">localhost</Machine>
<User Condition="'$(User)' == ''"></User>
<Password Condition="'$(User)' == ''"></Password>
<AppPoolName Condition="'$(AppPoolName)' == ''">TestAppPool</AppPoolName>
<WebSiteName Condition="'$(WebSiteName)' == ''">TestSite</WebSiteName>
<WebSitePort Condition="'$(WebSitePort)' == ''">8088</WebSitePort>
<WebSitePhysicalPath Condition="'$(WebSitePhysicalPath)' == ''">D:\Inetpub\TestSite</WebSitePhysicalPath>
<AppPoolExists>False</AppPoolExists>
</PropertyGroup>
<UsingTask TaskName="MSBuild.WMI.AppPool" AssemblyFile="MSBuild.WMI\bin\Debug\MSBuild.WMI.dll"/>
<UsingTask TaskName="MSBuild.WMI.WebSite" AssemblyFile="MSBuild.WMI\bin\Debug\MSBuild.WMI.dll"/>
<!-- set up variables -->
<Target Name="_Setup">
<MSBuild.WMI.AppPool TaskAction="CheckExists" AppPoolName="$(AppPoolName)" Machine="$(Machine)" UserName="$(User)" Password="$(Password)">
<Output TaskParameter="Exists" PropertyName="AppPoolExists"/>
</MSBuild.WMI.AppPool>
<MSBuild.WMI.WebSite TaskAction="CheckExists" SiteName="$(WebSiteName)" Machine="$(Machine)" UserName="$(User)" Password="$(Password)">
<Output TaskParameter="Exists" PropertyName="WebSiteExists"/>
</MSBuild.WMI.WebSite>
</Target>
<!-- stop web site -->
<Target Name="_StopSite">
<MSBuild.WMI.WebSite TaskAction="Stop" SiteName="$(WebSiteName)" Machine="$(Machine)" UserName="$(User)" Password="$(Password)" Condition="'$(WebSiteExists)'=='True'" />
<MSBuild.WMI.AppPool TaskAction="Stop" AppPoolName="$(AppPoolName)" Machine="$(Machine)" UserName="$(User)" Password="$(Password)" Condition="'$(AppPoolExists)'=='True'" />
</Target>
<!-- stop and deploy web site -->
<Target Name="_StopAndDeployWebSite">
<!-- stop (if it exists) -->
<CallTarget Targets="_StopSite" />
<!-- create AppPool (if does not exist) -->
<MSBuild.WMI.AppPool TaskAction="Create" AppPoolName="$(AppPoolName)" Machine="$(Machine)" UserName="$(User)" Password="$(Password)" Condition="'$(AppPoolExists)'=='False'" />
<!-- create web site (if does not exist)-->
<MSBuild.WMI.WebSite TaskAction="Create" SiteName="$(WebSiteName)" Port="$(WebSitePort)"
AppPoolName="$(AppPoolName)" Machine="$(Machine)" UserName="$(User)" Password="$(Password)" PhysicalPath="$(WebSitePhysicalPath)"
Condition="'$(WebSiteExists)'=='False'" />
</Target>
<!-- start all application parts -->
<Target Name="_StartAll">
<MSBuild.WMI.AppPool TaskAction="Start" AppPoolName="$(AppPoolName)" Machine="$(Machine)" UserName="$(User)" Password="$(Password)" />
<MSBuild.WMI.WebSite TaskAction="Start" SiteName="$(WebSiteName)" Machine="$(Machine)" UserName="$(User)" Password="$(Password)" />
</Target>
<!-- deployment implementation -->
<Target Name="_DeployAll">
<CallTarget Targets="_StopAndDeployWebSite" />
<CallTarget Targets="_StartAll" />
</Target>
<!-- deploy application -->
<Target Name="Deploy" DependsOnTargets="_Setup">
<CallTarget Targets="_DeployAll" />
</Target>
<!-- stop application -->
<Target Name="StopApplication" DependsOnTargets="_Setup">
<CallTarget Targets="_StopWebSite" />
</Target>
<!-- start application -->
<Target Name="StartApplication" DependsOnTargets="_Setup">
<CallTarget Targets="_StartAll" />
</Target>
</Project>