setup_iis.ps1 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. param($action)
  2. $ErrorActionPreference = 'Stop'
  3. # From http://zduck.com/2012/powershell-batch-files-exit-codes/
  4. function Exec
  5. {
  6. [CmdletBinding()]
  7. param (
  8. [Parameter(Position=0, Mandatory=1)]
  9. [scriptblock]$Command,
  10. [Parameter(Position=1, Mandatory=0)]
  11. [string]$ErrorMessage = "Execution of command failed.`n$Command"
  12. )
  13. & $Command
  14. if ($LastExitCode -ne 0) {
  15. throw "Exec: $ErrorMessage"
  16. }
  17. }
  18. $source = "C:\FrameworkBenchmarks\aspnet-stripped\src"
  19. # Stop
  20. if (Get-WebSite -Name Benchmarks) { Remove-WebSite -Name Benchmarks }
  21. if ($action -eq 'start') {
  22. # Because we don't use msbuild to compile the code, we do this all manually.
  23. Exec { & .\NuGet.exe install -o src\packages src\packages.config }
  24. if (-Not (Test-Path src\bin)) { New-Item -Path src\bin -ItemType directory | Out-Null }
  25. $dlls = Get-ChildItem -path src\packages -recurse -include *.dll
  26. foreach ($dll in $dlls) {
  27. Copy-Item $dll src\bin
  28. }
  29. # Create a website in IIS
  30. New-WebSite -Name Benchmarks -Port 8080 -PhysicalPath $source
  31. }