tag:help.appveyor.com,2012-11-13:/discussions/problems/1219-iisexpress-not-workingAppVeyor: Discussion 2018-10-19T08:16:54Ztag:help.appveyor.com,2012-11-13:Comment/355610962014-12-16T22:35:40Z2014-12-16T22:35:40ZIISExpress not working<div><p>Might be too little timeout?</p>
<p>I did a simple test here and it worked: <a href=
"https://ci.appveyor.com/project/appvyr/simple-console/build/1.0.52">
https://ci.appveyor.com/project/appvyr/simple-console/build/1.0.52</a></p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/355610962014-12-17T11:52:24Z2014-12-17T11:52:24ZIISExpress not working<div><p>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.</p>
<p>Interestingly there appears to be a difference in how your job
runs:</p>
<pre>
<code>Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
1 RunIisExpress BackgroundJob Running True localhost & 'C:\Program Files (x...</code>
</pre>
<p>And how mine runs:</p>
<pre>
<code>Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
1 RunIisExpress BackgroundJob Completed False localhost ... ```
Note mine is "Completed". Not sure why that would be. Do you have any unusual settings set in your test project perhaps?</code>
</pre>
<p>param([string]$buildFolder)</p>
<p>$jVUNDemo = "$($buildFolder)\jVUNDemo" $staticSiteParentPath =
(get-item $buildFolder).Parent.FullName $staticSite = "static-site"
$staticSitePath = "$($staticSiteParentPath)\$($staticSite)" $port =
57612 $servedAt = "<a href=
"http://localhost:$($port)/&quot">http://localhost:$($port)/&quot</a>;
write-host "jVUNDemo location: $jVUNDemo"<br>
write-host "static site parent location: $staticSiteParentPath"<br>
write-host "static site location: $staticSitePath"</p>
<p>write-host "Spin up jVUNDemo site at $($servedAt)"<br>
$iisExpressScript = { & 'C:\Program Files (x86)\IIS
Express\iisexpress.exe' /path:$jVUNDemo /port:$port } $job =
Start-Job -Name RunIisExpress -Scriptblock $iisExpressScript</p>
<p>write-host "Wait a moment for IIS to startup"<br>
write-host "$(Get-Date -format 'u') Job state: $($job.state)"<br>
Wait-Job $job -Timeout 30<br>
write-host "$(Get-Date -format 'u') Job state: $($job.state)"</p>
<p>if (Test-Path $staticSitePath) {<br>
write-host "Removing $($staticSitePath)..." Remove-Item -path
$staticSitePath -Recurse -Force }</p>
<p>Write-Host "Send request to IIS Express..."<br>
Invoke-RestMethod $servedAt</p>
<p>write-host "Create static version of demo site here:
$($staticSitePath)"<br>
Push-Location $staticSiteParentPath<br>
wget.exe --recursive --convert-links -E
--directory-prefix=$staticSite --no-host-directories --debug
$servedAt<br>
Pop-Location</p>
<p>write-host "Shut down jVUNDemo site"<br>
write-host "$(Get-Date -format 'u') Job state: $($job.state)"<br>
Stop-Job $job<br>
do {<br>
Start-sleep -s 5 } while ($job.state -eq "Running") write-host
"$(Get-Date -format 'u') Job state: $($job.state)"<br>
receive-job $job | out-file jobs.log -append<br>
cat jobs.log<br>
Remove-Job $job</p>
<p>if (Test-Path $staticSitePath) {<br>
write-host "Contents of $($staticSitePath)" ls $staticSitePath
}</p>
<pre>
</pre></div>johnny_reillytag:help.appveyor.com,2012-11-13:Comment/355610962014-12-17T12:09:14Z2014-12-17T12:09:14ZIISExpress not working<div><p>Interestingly I tried chaining on your example code to the end
of my PowerShell script as follows:</p>
<pre>
<code>#################
Write-Host "Create default.htm..."
'<h1>Hello, world!</h1>' | Out-File $buildFolder\default.htm -Encoding UTF8
Write-Host "Start IIS Express..."
Start-Job -Name RunIisExpress2 -Scriptblock {& 'C:\Program Files (x86)\IIS Express\iisexpress.exe' /path:$buildFolder /port:57614}
Wait-Job -Name RunIisExpress2 -Timeout 30
Write-Host "Send request to IIS Express..."
Invoke-RestMethod http://localhost:57614
#################</code>
</pre>
<p>This also fails in my build with this message:</p>
<pre>
<code>Invoke-RestMethod : Unable to connect to the remote server
At C:\projects\jquery-validation-unobtrusive-native\makeStatic.ps1:63 char:1
+ Invoke-RestMethod http://localhost:57614
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand</code>
</pre>
<p>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:</p>
<pre>
<code>#---------------------------------#
# general configuration #
#---------------------------------#
# version format
version: 1.0.{build}
#---------------------------------#
# environment configuration #
#---------------------------------#
# scripts that are called at very beginning, before repo cloning
init:
- ps: git config --global user.email "johnny_reilly@hotmail.com"
- ps: git config --global user.name "johnnyreilly"
# environment variables
environment:
GithubUsername: johnnyreilly
GithubPassword:
secure: ilM6UXjXXOmFLz6pDWsoOA==
branches:
only:
- master
install:
- ps: choco install wget
build:
verbosity: minimal
after_build:
- ps: git remote -v
- ps: ./makeStatic.ps1 $env:APPVEYOR_BUILD_FOLDER</code>
</pre></div>johnny_reillytag:help.appveyor.com,2012-11-13:Comment/355610962014-12-17T15:16:47Z2014-12-17T15:16:47ZIISExpress not working<div><p><a href=
"https://ci.appveyor.com/project/JohnReilly/jquery-validation-unobtrusive-native/build/1.0.37">
This was the failing build with your code dropped in</a></p></div>johnny_reillytag:help.appveyor.com,2012-11-13:Comment/355610962014-12-17T18:01:18Z2014-12-17T18:01:18ZIISExpress not working<div><p><code>Completed</code> 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
(<code>$LastExitCode</code>)</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/355610962014-12-19T14:07:50Z2014-12-19T14:07:50ZIISExpress not working<div><p>Hi Feodor,</p>
<p>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...</p>
<p>Example build <a href=
"https://ci.appveyor.com/project/JohnReilly/jquery-validation-unobtrusive-native/build/1.0.52">
here</a></p></div>johnny_reillytag:help.appveyor.com,2012-11-13:Comment/355610962014-12-19T17:17:52Z2014-12-19T17:17:52ZIISExpress not working<div><p>Hi Johnny,</p>
<p>Glad it finally works!</p>
<p>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
<code>2>&1</code> redirection: <a href=
"http://steve-jansen.github.io/guides/windows-batch-scripting/part-4-stdin-stdout-stderr.html">
http://steve-jansen.github.io/guides/windows-batch-scripting/part-4...</a></p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/355610962014-12-20T13:53:36Z2014-12-20T13:53:36ZIISExpress not working<div><p>Hi Feodor,</p>
<p>Boom! It worked!</p>
<p>My shell knowledge is much weaker than I'd like it to be
(something |'m working on). So you've taught me something -
thanks!</p></div>johnny_reilly