WebDev.WebServer PowerShell Function

In experimenting with NWSGI yesterday, I found I wanted the ability to launch the development web server that ships with Visual Studio (WebDev.WebServer.exe) from the command line. I hacked up the following PowerShell function and dropped it into my $profile so I can easily launch the web server in any directory any time I need. Thought I’d share:

function webdev($path,$port=8080,$vpath='/')
{
    $spath = 'C:\Program Files\Common Files\microsoft shared\DevServer9.0\WebDev.WebServer.EXE'
    $rpath = resolve-path $path  
    $params = "/path:`"$rpath`" /port:$port /vpath:$vpath"  

    $ignore = [System.Diagnostics.Process]::Start($spath, $params)  
    "Started WebDev Server for '$path' directory on port $port"  
}

There’s probably an easier way to launch an exe with parameters than Sys.Diags.Process.Start, but it works. Using resolve-path is the key, that lets me pass in a relative path on the command line, but the script converts it to an absolute path in order to pass it to the webdev server. Also, I’m not sure I should have hard coded the path to the exe, but again it works and it’s not like it’s tough to change.

Enjoy.

Update: Tomas Restrepo pointed out an easier way to start the process:

&'C:\Program Files\Common Files\microsoft shared\DevServer9.0\WebDev.WebServer.EXE' "/path:$rpath" "/port:$port" "/vpath:$vpath"

I couldn’t figure out how to correctly launch the exe when the physical path to serve has a space in it. Thanks Tomas.

Morning Coffee 159

As you might expect, these morning coffee posts are going to get more dev focused as well as more IPy focused.

  • One of the cool things we showed @ PyCon was Django running on the latest drop of IronPython. IPy lead developer Dino Viehand posted a blog entry (for the first time in 28 months!) showing the basic Python DB provider for SQL Server he put together. Hopefully, we won’t have to wait another two and a half years for Dino’s next post.
  • Speaking of IronPython, some of my new teammates pointed me to Michael Foord’s Planet IronPython aggregate news site. Michael is IPy developer for Resolver Systems (the cool spreadsheet app hybrid I wrote about @ Lang.NET) and he’s working on an IPy book.
  • Still speaking of IPy, Jeff Hardy dropped his first release of NWSGI, an port of Python’s Web Service Gateway Interface spec to ASP.NET and IPy. I can’t wait to see NWSGI combined Django running on IPy like Dino demoed @ PyCon. Congrats Jeff!
  • Scott Hanselman’s post on Twitter reminds me that I recently started twittering myself. I haven’t worked it into my daily routine, so it gets updated only occasionally, but after reading Scott’s post, I’m thinking it’s cooler than it appears on the surface.
  • In surprising news, Microsoft is going to start collaborating with IBM’s Eclipse Foundation, to make it easier to it easier to write apps for Windows in Java. I would think this is a very cool thing, but apparently Ted Neward – who’s knowledge of JavaWorld far eclipses (ha ha) my own – thinks “the skin here is just too sensitive” and that this move might cause more controversy between MS and Java. However, he seems to imply the controversy would be between MS & Sun (Eclipse is obviously named as a jab @ Sun) rather than between MS & the Java community.

Lunchtime Coffee 153

Morning Coffee 146

  • The writers strike is officially over. Everyone goes back to work today. Thomas Cleaver has what I thought was the best post summarizing how the writers won. TV Guide has a rundown of how and when various shows will resume. I can’t wait to see Daily Show and Colbert Report tonight. Lost – aka the best show on TV – looks like it will be getting five more episodes (in addition to the eight shot before the strike).
  • Speaking of TV, Battlestar Galactica Fans: circle April 4th on your calendar.
  • Obama won all three “Potomac Primaries” yesterday, and is now the Democratic front-runner, though there’s a long way to go before the convention. Scott Adams of Dilbert fame has a great take on presidential experience – I’m guessing he’s an Obama fan.
  • In minor acquisition news, Microsoft is acquiring Caligari, makers of 3D modeling tool trueSpace. The Caligari folks are joining the Virtual Earth team, though I wonder what the XNA folks think of the acquisition. This isn’t the first 3D modeling product Microsoft ever acquired – we owned Softimage for four years in the ’90s.
  • Scott Hanselman and Tomas Resprepo both write about PowerShellPlus, which I saw week before last @ Lang.NET. Scott really likes it, for both PS novices and gurus, but Tomas thinks the UI is busy, based on the screenshots. Personally, I’m not doing much PS work lately – occasional one off stuff, but that’s it – so it doesn’t seem worth the effort.
  • Speaking of Scott & Tomas, Scott also has a nice gallery of VS themes. I’m partial to Tomas’ Ragnarok Grey. Is there a VSThemesGallery.com site somewhere?
  • Still speaking of Scott, he points to the new ASP.NET Developer Wiki (beta). I poked around, but didn’t find anything shiny. I was very surprised that searching for “MVC” returned no results.
  • Speaking of MVC, Scott Guthrie has a rundown on what’s coming in the MIX preview release of ASP.NET MVC. Biggest news IMO is that it’s /bin deployable – i.e. you don’t need your hoster to do anything special to support MVC (assuming they already support ASP.NET 3.5). Also big news, they’re releasing the source so you can build and patch (and enhance?) it yourself.
  • Chris Taveres continues is ObjectBuilder series and Tomas continues is DLR Notes series. BTW, my F# based DLR experimentation continues, albeit slowly (frakking day job). Hope to be able to post on this soon.
  • One of the things driving my interest in F# is manycore. An interesting tangent to manycore is general purpose programming on graphics processing units (aka GPGPU). MS Research just released a new version of Accelerator, just such a GPGPU system. I personally haven’t played with it – I’ve been focused on writing parsers, not parallel code.
  • Is XQuery really “a promising technology of the future” as Don Box suggests? I see exactly zero demand or use for it in my day-to-day work. Of course, Don’s paid to build future platform goo, so maybe it is promising and Don’s afore-mentioned goo will leverage it, though I remain skeptical. As for XML being “Done like a well-cooked steak”, I’d say XML is like a great steak cooked perfectly, except it’s done exactly how you don’t like it. You can appreciate its quality, but you don’t really enjoy it as much as you could have.

Morning Eggnog 132

  • My parents are coming into town tomorrow so I’m off for the remaining week or so of the year. Blogging will likely be non-existent, unless I blog something I come up with while geeking out with my dad.
  • Juergen van Gael demonstrates how to use TPL from F#. He wrote this once before using F#’s async workflows feature. I like the TPL version, though the new Action<int>(RowTask) is a little wordy. I’m guessing the eventual F# syntax will probably become something compact like action RowTask. (via Don Syme)
  • Andrew Peter ported RoR’s Haml view engine to ASP.NET MVC, calling the result NHaml. I haven’t played around with the new MVC stuff much, but I’m guessing ASP.NET’s control-based approach doesn’t work well when you separate out the controller code. If I’m manually authoring view templates, I’d much rather type NHaml’s syntax than the standard ASP.NET <% …%> syntax. On the other hand, there aren’t any design tools out there today handle the NHaml syntax. Also, I wonder if Andrew is working on a Sass port. (via DNK)