Long and short is that I have a publish that will upload via SFTP. SFTP is not natively supported by Visual Studio, and I'd rather not use VS extensions. My solution so far is modifying the vcxproj file and jumping through several hoops in order to get a program to run after the publish (which is pointed to local disk) completes - the program then uploads them to website via SFTP.
All I need is a way for a C++ program to read the Output Window of Visual Studio in order to find text "publish finished". Right now the program runs on a delay timer which isn't exactly reliable.
Cheers...
.
While it's not required for an answer, here's all the details about hoops I had to jump through to run a batch file after publish.
Firstly, post-publish events are not editable in Visual Studio; you have to manually add them to the project via a text editor on the vcxproj file.
Secondly, the formatting of these events are extremely specific; it's all too easy for an "error 9009 command not found" with no actual specifics. Full file paths with parameters, all quoted properly? Not good enough.
Thirdly, the AfterPublish event doesn't actually run after the publish... but before the publish. Which is ridiculously stupid, but led to this "try and figure out when it actually finished" problem.
Fourthly, the environment of the program that VS runs from AfterPublish isn't the usual command prompt environment. Trying to use built-in commands doesn't work properly, even when you specify the full file path to them.
I had to use two layers of cmd /C to bypass it. One layer for some reason spawned no console window at all.
Fifthly, VS waits for the program to finish before moving on in the publish. That's something that is very normal, but not helpful for a program that runs before the publish. Using "start" command doesn't work, it still waits for the batch file to end.
I had to create my own program to run a detached process. I based it on this answer, but with some extra debug. (I am unable to run it without full path, and I can't run it with full path even in System32, "file not found", but that's not a chronic problem.)
So now I've got a vcxproj, that runs a program, that starts a detached program, that starts cmd which starts cmd which runs a batch file, which waits for 15 seconds, and then runs the upload app (pscp).
Every attempt to remove part of this chain has failed. I've given up on that; now I just want it to not be depending on the publishing user to be there; you have to click a confirm for overwriting already published versions, and a time delay is a race condition. Not that every publish is an overwrite, but there you go.
Any help with getting a C++ program to resume after Output Window displays "Publish Finished" would be appreciated. I've looked around but nothing crosses all the gaps; EnumChildWindows() seems to have mostly blank window titles and I can't figure out how to read the text content as opposed to window caption anyway.
Cheers again
Aucun commentaire:
Enregistrer un commentaire