简体   繁体   English

如何部署应用程序并包括IIS设置?

[英]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 . 我正在寻找一种方法,用于从DEVITGPRO部署应用程序,网站和Web服务。 I am not referring only to files included in the projects, but also settings from IIS , files/folders permissions, etc. 我不仅指项目中包含的文件,还指IIS设置,文件/文件夹权限等。

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). 例如,本周末我们必须将新的应用程序从ITG部署到PRO ,并且PRO AppPool被设置为运行.NET 2.0 (来自先前版本)。 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 . 当前,我们正在使用VS 2013C# 4.xIIS 8.xTFS 2013 The question here is, if there is a way to deploy an application with a "single click". 这里的问题是,是否可以通过“单击”来部署应用程序。 Is MSBuild suitable for this task? MSBuild是否适合此任务? (I have no experience on MSBuild , I just found some stuff while Googling, and I am wondering if I need to go deeper). (我没有使用MSBuild经验,我在谷歌搜索时发现了一些东西,我想知道是否需要更进一步)。 Can TFS read those settings from the source machine and copy them on the target somehow? TFS可以从源计算机读取这些设置,然后以某种方式将它们复制到目标计算机上吗? 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. 我们希望停留在Microsoft的圈子内,但是如果其他事情确实做到了,我们可能会考虑。

This can be accomplished via PowerShell . 这可以通过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. 我不是PowerShell专家,所以我的语法可能不遵循良好实践等。但是我有一个脚本,用于创建生产和测试网站并预配置几个IIS设置。 I then do my deployment from VS, but you could expand the script to perform the build and deployment for you too. 然后,我从VS进行部署,但是您也可以扩展脚本来为您执行构建和部署。 It utilizes the WebAdministration module for configuring IIS. 它利用WebAdministration模块配置IIS。

CreateIntranetSite.ps1 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);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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