Thursday, April 8, 2010

ClickOnce and OpenVMS

Tasked with deploying our Windows ClickOnce application to Apache running on OpenVMS, I never imagined the pain I'd encounter.
Yes, it can be made to work.
First requirement, the OpenVMS server must be ODS5 to handle long filenames with spaces and extra dots.
I set up Team Systems to automatically build and FTP the deployment to the Apache directories on the OpenVMS server.  I set up a custom task for the FTP which utilized the FTP classes built into .NET.  This proved to be a huge mistake.  It appears that the FTP conventions Microsoft uses doesn't play well with the FTP conventions used by OpenVMS.  So long as I only uploaded files to directories directly under the root or directly to the default user directory, I had no problems.  But the problem was with deploying to subdirectories, particularly if they had those spaces or extra dots.  There was no way to properly define the path using the URI convention that .NET uses.  Sure, you can use "%20" to represent the space, but for some reason OpenVMS got real confused by the URI convention.  OpenVMS uses brackets ("[" and "]") for directory identification, with periods for subdirectories ("[MAIN.SUBDIRECTORY]" as opposed to "c:\MAIN\SUBDIRECTORY\"), and trying to FTP with a URI ("ftp://MAIN/SUBDIRECTORY") doesn't translate well when there are special characters in the URI.
And no matter what I did, I could not make it work.
I finally succeeded by instead creating a DOS-style FTP command script and using Process.Start to shell out to the built-in Windows FTP command.  It turned out not being all that much more complicated than using the built-in .NET FTP.  The only thing I really lost was accurancy in determining success or fail of the transfer.  I may be able to handle this by capturing standard error on Process.Start, but this is something for another time--when I'm bored or something.