IISExpress not working
Hi,
https://ci.appveyor.com/project/JohnReilly/jquery-validation-unobtr...
My build runs a powershell script that, briefly, spins up the ASP.Net MVC project jVUNDemo using IISExpress:
write-host "Spin up jVUNDemo site"
Start-Job -Name RunIisExpress -Scriptblock {& 'C:\Program Files (x86)\IIS Express\iisexpress.exe' /path:$jVUNDemo /port:57612}
write-host "Wait a moment for IIS to startup"
Wait-Job -Name RunIisExpress -Timeout 5
if (Test-Path $staticSite) {
write-host "Removing $($staticSite)..."
Remove-Item -path $staticSite -Recurse -Force
}
write-host "Create static version of demo site here: $($staticSite)"
Push-Location $staticSiteParent
wget.exe --recursive --convert-links -E --directory-prefix=static-site --no-host-directories http://localhost:57612/
Pop-Location
write-host "Shut down jVUNDemo site"
Receive-Job -Name RunIisExpress
Get-Job -Name RunIisExpress | Stop-Job
Get-Job -Name RunIisExpress | Remove-Job
It does this so we can use wget to generate a static site. We plan to use that to publish to GitHub Pages. However, whilst this runs fine locally (on my Windows 8.1 machine) it fails as part of the AppVeyor build:
wget.exe : --2014-12-16 16:05:28-- http://localhost:57612/
At C:\projects\jquery-validation-unobtrusive-native\makeStatic.ps1:23 char:1
+ wget.exe --recursive --convert-links -E --directory-prefix=static-site --no-host ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (--2014-12-16 16...ocalhost:57612/:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Resolving localhost...
127.0.0.1
Connecting to localhost|127.0.0.1|:57612...
failed: Connection refused.
It seems we cannot start IISExpress. Is there a way to rectify this?
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Feodor Fitsner on 16 Dec, 2014 10:35 PM
Might be too little timeout?
I did a simple test here and it worked: https://ci.appveyor.com/project/appvyr/simple-console/build/1.0.52
2 Posted by johnny_reilly on 17 Dec, 2014 11:52 AM
Thanks for the example Feodor. I upped my timeout to 30 seconds but it doesn't seem to have made a difference. I've been trying out different things but nothing seems to make a difference.
Interestingly there appears to be a difference in how your job runs:
And how mine runs:
param([string]$buildFolder)
$jVUNDemo = "$($buildFolder)\jVUNDemo" $staticSiteParentPath = (get-item $buildFolder).Parent.FullName $staticSite = "static-site" $staticSitePath = "$($staticSiteParentPath)\$($staticSite)" $port = 57612 $servedAt = "http://localhost:$($port)/" write-host "jVUNDemo location: $jVUNDemo"
write-host "static site parent location: $staticSiteParentPath"
write-host "static site location: $staticSitePath"
write-host "Spin up jVUNDemo site at $($servedAt)"
$iisExpressScript = { & 'C:\Program Files (x86)\IIS Express\iisexpress.exe' /path:$jVUNDemo /port:$port } $job = Start-Job -Name RunIisExpress -Scriptblock $iisExpressScript
write-host "Wait a moment for IIS to startup"
write-host "$(Get-Date -format 'u') Job state: $($job.state)"
Wait-Job $job -Timeout 30
write-host "$(Get-Date -format 'u') Job state: $($job.state)"
if (Test-Path $staticSitePath) {
write-host "Removing $($staticSitePath)..." Remove-Item -path $staticSitePath -Recurse -Force }
Write-Host "Send request to IIS Express..."
Invoke-RestMethod $servedAt
write-host "Create static version of demo site here: $($staticSitePath)"
Push-Location $staticSiteParentPath
wget.exe --recursive --convert-links -E --directory-prefix=$staticSite --no-host-directories --debug $servedAt
Pop-Location
write-host "Shut down jVUNDemo site"
write-host "$(Get-Date -format 'u') Job state: $($job.state)"
Stop-Job $job
do {
Start-sleep -s 5 } while ($job.state -eq "Running") write-host "$(Get-Date -format 'u') Job state: $($job.state)"
receive-job $job | out-file jobs.log -append
cat jobs.log
Remove-Job $job
if (Test-Path $staticSitePath) {
write-host "Contents of $($staticSitePath)" ls $staticSitePath }
3 Posted by johnny_reilly on 17 Dec, 2014 12:09 PM
Interestingly I tried chaining on your example code to the end of my PowerShell script as follows:
This also fails in my build with this message:
This makes me think there's some kind of environmental difference between your project and mine. Any thoughts on what it might be? This is my appVeyor.yml:
4 Posted by johnny_reilly on 17 Dec, 2014 03:16 PM
This was the failing build with your code dropped in
Support Staff 5 Posted by Feodor Fitsner on 17 Dec, 2014 06:01 PM
Completed
could be mean the process immediately exited with non-zero code. What could be a problem? I think it could be due to site home folder or already taken port or something else. Try seeing what exit code IIS Express returns ($LastExitCode
)6 Posted by johnny_reilly on 19 Dec, 2014 02:07 PM
Hi Feodor,
I got round the issue by switching from jobs to processes in Powershell. Even though it all works as expected AppVeyor is showing the output in the "red angry text of sin". Which is a bit weird. Any idea why? As I see it seems to work fine otherwise...
Example build here
Support Staff 7 Posted by Feodor Fitsner on 19 Dec, 2014 05:17 PM
Hi Johnny,
Glad it finally works!
Regarding red - that's an easy one - seems wget.exe writes to STDERR (and it's a usual habit for most unix tools). PowerShell treats anything in STDERR as kind of RemoteException. Try using
2>&1
redirection: http://steve-jansen.github.io/guides/windows-batch-scripting/part-4...8 Posted by johnny_reilly on 20 Dec, 2014 01:53 PM
Hi Feodor,
Boom! It worked!
My shell knowledge is much weaker than I'd like it to be (something |'m working on). So you've taught me something - thanks!
johnny_reilly closed this discussion on 31 Dec, 2014 11:22 AM.