简体   繁体   中英

How to deploy applications and include IIS settings?

I am looking for a methodology of how to deploy applications, websites and web services from DEV to ITG and PRO . I am not referring only to files included in the projects, but also settings from IIS , files/folders permissions, etc.

For example, this weekend we had to deploy a new application from ITG to PRO , and PRO AppPool was set to run .NET 2.0 (from previous version). It took us sometime to realize what was going on, leading of course to a longer downtime than expected.

Currently we are using VS 2013 , C# 4.x , IIS 8.x and TFS 2013 . The question here is, if there is a way to deploy an application with a "single click". Is MSBuild suitable for this task? (I have no experience on MSBuild , I just found some stuff while Googling, and I am wondering if I need to go deeper). Can TFS read those settings from the source machine and copy them on the target somehow? Is there any other tool than can complete this task? We would like to stay inside Microsoft's circle, however if something else does exactly that, we might consider it.

This can be accomplished via PowerShell . I'm not a PowerShell expert, so my syntax on this is probably not following good practice etc. But I have a script I use to create production and test websites and pre-configure a couple of IIS settings. I then do my deployment from VS, but you could expand the script to perform the build and deployment for you too. It utilizes the WebAdministration module for configuring IIS.

CreateIntranetSite.ps1

param([string]$SiteName, [string]$Hostname)

if($SiteName -eq '') {
Write-Error "You must provide a SiteName parameter."
}
elseif($HostName -eq ''){
Write-Error "You must provide a HostName parameter."
}
else {
Invoke-Command -ComputerName $HostName -credential DOMAIN\mason.sa -ArgumentList $SiteName -ScriptBlock {
param([string]$SiteName)
$IntranetRoot = "E:\Intranet"
$DefaultHtml = "<html><head><title>$SiteName</title></head><body><h1>$SiteName</h1><p>The $SiteName virtual application has been successfully configured.</p></body></html>"

#Import IIS tools
Import-Module "WebAdministration"

#Create Folder
New-Item $IntranetRoot\$SiteName -type Directory

#Create Default Page
Set-Content $IntranetRoot\$SiteName\index.html $DefaultHtml

#Create App Pool
New-WebAppPool $SiteName

#Create Virtual Application
New-WebApplication -Name $SiteName -Site "Intranet" -PhysicalPath $IntranetRoot\$SiteName -ApplicationPool $SiteName

#Configuration Virtual Application

#Disable AnonymousAuthentication
Set-WebConfigurationProperty -filter /system.WebServer/security/authentication/AnonymousAuthentication -name enabled -value false -location Intranet/$SiteName

#Enable Windows Authentication
Set-WebConfigurationProperty -filter /system.WebServer/security/authentication/WindowsAuthentication -name enabled -value true -location Intranet/$SiteName

}

#Launch Browser to verify
$SiteUrl=''
if($HostName -eq 'wr-test01'){
$SiteUrl='https://testnet.termana.net/'+$SiteName
}
elseif($HostName -eq 'wr-web01'){
$SiteUrl='https://intranet.termana.net/'+$SiteName
}
$ie = new-object -com InternetExplorer.Application
$ie.Visible = $true
$ie.Navigate($SiteUrl);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM