
Iec6b3c56d464d26e4f1fc143e6a7804add67a35d I3f2d3a12fcb53759a906fcbae6fae768833d325e I566811521da16055a73c73052ffcd497aaa8e475 I2ee04b6d5aaa26d49243cf7e0b6045026f052625 I329620f3c8aa7e7f1bdd658cbaa8ea20d9aa4ba5 I5ff3d9146b4fbec74d8d65de84d7ab61d869725c Ib38fd52811812170bdd9bf9df90a66f1a2e6c8d9 I64ce3efaec6df2e402ca2acf6a3cf1a6f2bb1909 I66c3659ab0f33772d7a51c8961a37e32c65354c2 I29ce4a6ef165daa0fe60003301a0d807fd1cce42 Ibd2a4f55e2a64d9a992833200a791dbb20c41eca I16133a213ef25a1b374f10fa80cd5a03d1f40753 Ie09f32fcacfe70f436cad71e5749edf94be038ed Iaba6a6bf07ff223e41f705f0f1db5688a5290f5c I64a0474ecfe5ea38393fe681d520a7b6ce00d959 I270b3ce5ef776522a62d9622b36f0d6b50b9cc57 Ic5f6849ea166bb0295f84685b0a2b5c4701f972a I51190cb02255254a888f66404ecdc3dfc5be0386 I0c2180c603cd09e29d4e6c5e592b987e2b447972 Iae1cdbeb7fa3e49c2cb5cac7c92eceffef477e7e I6c643f58aada0a8525711bc452d0c581625f3d26 I9c4f999b1b3006b8ae5f18a030d5b30c7e85e03b I32eaad36edcb889b448c45ba36f4e97f7c87d1e5 I8c91c40a922690b475aac1c0a3b2c0c28274b130 I574fd1dbeea58dbf41f77d295dc03c23d2feaf96 Change-Id: I0ffb3c38c0c1b3aafa8617364e22036c47aaef76
153 lines
5.0 KiB
PowerShell
153 lines
5.0 KiB
PowerShell
|
|
trap {
|
|
&$TrapHandler
|
|
}
|
|
|
|
|
|
Function Register-WebApp {
|
|
<#
|
|
.LINKS
|
|
|
|
http://www.iis.net/learn/manage/powershell/powershell-snap-in-creating-web-sites-web-applications-virtual-directories-and-application-pools
|
|
#>
|
|
param (
|
|
[String] $Source,
|
|
[String] $Path = "C:\inetpub\wwwroot",
|
|
[String] $Name = "",
|
|
[String] $Username = "",
|
|
[String] $Password = ""
|
|
)
|
|
begin {
|
|
Show-InvocationInfo $MyInvocation
|
|
}
|
|
end {
|
|
Show-InvocationInfo $MyInvocation -End
|
|
}
|
|
process {
|
|
trap {
|
|
&$TrapHandler
|
|
}
|
|
|
|
Import-Module WebAdministration
|
|
|
|
if ($Name -eq "") {
|
|
$Name = @([IO.Path]::GetDirectoryName($Source) -split '\\')[-1]
|
|
if ($Name -eq "wwwroot") {
|
|
throw("Application pool name couldn't be 'wwwroot'.")
|
|
}
|
|
}
|
|
else {
|
|
$Path = [IO.Path]::Combine($Path, $Name)
|
|
}
|
|
|
|
$null = Copy-Item -Path $Source -Destination $Path -Recurse -Force
|
|
|
|
# Create new application pool
|
|
$AppPool = New-WebAppPool -Name $Name -Force
|
|
#$AppPool = Get-Item "IIS:\AppPools\$Name"
|
|
$AppPool.managedRuntimeVersion = 'v4.0'
|
|
$AppPool.managedPipelineMode = 'Classic'
|
|
$AppPool.processModel.loadUserProfile = $true
|
|
$AppPool.processModel.logonType = 'LogonBatch'
|
|
|
|
#Set Identity type
|
|
if ($Username -eq "") {
|
|
$AppPool.processModel.identityType = 'ApplicationPoolIdentity'
|
|
}
|
|
else {
|
|
$AppPool.processModel.identityType = 'SpecificUser'
|
|
$AppPool.processModel.userName = $Username
|
|
$AppPool.processModel.password = $Password
|
|
$null = $AppPool | Set-Item
|
|
}
|
|
|
|
|
|
# Create Website
|
|
$WebSite = New-WebSite -Name $Name -Port 80 -HostHeader $Name -PhysicalPath $Path -Force
|
|
#$WebSite = Get-Item "IIS:\Sites\$Name"
|
|
|
|
# Set the Application Pool
|
|
$null = Set-ItemProperty "IIS:\Sites\$Name" 'ApplicationPool' $Name
|
|
|
|
#Turn on Directory Browsing
|
|
#Set-WebConfigurationProperty -Filter '/system.webServer/directoryBrowse' -Name 'enabled' -Value $true -PSPath "IIS:\Sites\$Name"
|
|
|
|
# Update Authentication
|
|
#Set-WebConfigurationProperty -Filter '/system.WebServer/security/authentication/AnonymousAuthentication' -Name 'enabled' -Value $true -Location $name
|
|
#Set-WebConfigurationProperty -Filter '/system.WebServer/security/authentication/windowsAuthentication' -Name 'enabled' -Value $false -Location $Name
|
|
#Set-WebConfigurationProperty -Filter '/system.WebServer/security/authentication/basicAuthentication' -Name 'enabled' -Value $false -Location $Name
|
|
|
|
$null = $WebSite.Start()
|
|
|
|
$null = Add-Content -Path "C:\Windows\System32\Drivers\etc\hosts" -Value "127.0.0.1 $Name"
|
|
|
|
# Remove standard IIS 'Hello World' application from localhost:80
|
|
$null = Get-WebBinding 'Default Web Site' | Remove-WebBinding
|
|
# Add new application on http://localhost:80
|
|
$null = New-WebBinding -Name "$Name" -IP "*" -Port 80 -Protocol http
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Function Deploy-WebAppFromGit {
|
|
param (
|
|
[String] $URL,
|
|
[String] $TempPath = [IO.Path]::Combine([IO.Path]::GetTempPath(), [IO.Path]::GetRandomFileName()),
|
|
[String] $OutputPath = [IO.Path]::Combine([IO.Path]::GetTempPath(), [IO.Path]::GetRandomFileName())
|
|
)
|
|
begin {
|
|
Show-InvocationInfo $MyInvocation
|
|
}
|
|
end {
|
|
Show-InvocationInfo $MyInvocation -End
|
|
}
|
|
process {
|
|
trap {
|
|
&$TrapHandler
|
|
}
|
|
|
|
Write-Log "TempPath = '$TempPath'"
|
|
Write-Log "OutputPath = '$OutputPath'"
|
|
|
|
|
|
# Fetch web application
|
|
#----------------------
|
|
Write-Log "Fetching sources from Git ..."
|
|
|
|
$null = New-Item -Path $TempPath -ItemType Container
|
|
$null = Exec -FilePath 'git.exe' -ArgumentList @('clone', $URL) -WorkingDir $TempPath -RedirectStreams
|
|
|
|
$Path = @(Get-ChildItem $TempPath)[0].FullName
|
|
#----------------------
|
|
|
|
|
|
# Build web application
|
|
#----------------------
|
|
Write-Log "Building sources ..."
|
|
|
|
$msbuild = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe"
|
|
|
|
$null = New-Item -Path $OutputPath -ItemType Container
|
|
|
|
$SlnFiles = @(Get-ChildItem -Path $Path -Filter *.sln -Recurse)
|
|
|
|
# Start new processs with additional env variables:
|
|
#* VisualStudioVersion = "10.0"
|
|
#* EnableNuGetPackageRestore = "true"
|
|
$null = Exec -FilePath $msbuild `
|
|
-ArgumentList @($SlnFiles[0].FullName, "/p:OutputPath=$OutputPath") `
|
|
-Environment @{'VisualStudioVersion' = '10.0'; 'EnableNuGetPackageRestore' = 'true'} `
|
|
-RedirectStreams
|
|
|
|
$AppFolder = @(Get-ChildItem ([IO.Path]::Combine($OutputPath, '_PublishedWebsites')))[0]
|
|
#----------------------
|
|
|
|
|
|
# Install web application
|
|
#------------------------
|
|
$null = Register-WebApp -Source $AppFolder.FullName -Name $AppFolder.Name
|
|
#------------------------
|
|
}
|
|
}
|