Build code in vscode using external http server - visual-studio-code

Our code building process is done via an http server which starts the build process after receiving a project uuid from the build command. Once the server starts the compilation, GCC compatible output can be fetched from it.
Note: only my extension is aware of the project uuid which is different per workspace.
AFAIU I can implement it by:
programmatically adding a task which will call a script with the correct workspace uuid. Is this possible?
Having my extension manage the build process. This seems to be far from supported.
Bottom line, I'm trying to avoid asking the user to add anything to the configuration files and I want to completely manage the build process.
Thanks!

As I didn't find a suitable only vscode solution I did the following:
Defined a helper script which I executed as the task. The helper script was respojnsible for the communication against the HTTP server.
I registered the task using vscode.workspace.registerTaskProvider API, and made sure to register it only after figuring out the UUID.
Then in the task itself I executed the helper script.
(A nice task register example can be found here: https://github.com/Microsoft/vscode-extension-samples/tree/master/task-provider-sample)

Related

Running Alteryx flows from command line

I'm trying to figure out if I can launch a pre-built Alteryx workflow without launching the Designer - and without having Alteryx Server.
I came across a helpful post on Alteryx uses by #Runonthespot that, among other things, addressed running workflows from the command line, but doesn't go into detail. That discussion is here: https://stackoverflow.com/a/30469848/4313331. I don't have the rep to comment on his post and the question is closed.
He writes:
"Flows are runnable from the commandline on a server, and easiest way I've found (besides using Alteryx's own scheduler) is to save as an "App", and then run from the command line using the Alteryx engine executable, passing it parameters via xml file. You can save a sample xml parameter file from your flow by hitting the magic wand button (after saving the flow as a .yxwz (app)) This brings up a panel that lets you set the variables, and that panel has a handy "save" button which generates an xml file in the right format."
So, I'm looking for more info on this process. Is it simply a question of using Alteryx Server? Or is this a more interesting work around?
Thanks.
Yes, you can run a workflow (used generally to refer to a workflow, macro, or analytical app) without launching the Designer. You'll first need to understand how to run the workflow from the command line. The AlteryxEngineCmd.exe executable runs a workflow. It is located in the Alteryx install path in the bin subfolder. Here is where mine is located:
C:\Program Files\Alteryx\bin
It allows an additional parameter of an XML file with interface values. This is documented for analytical apps ONLY though it does work for macros as well. This is based on my extensive use of this undocumented feature.
Below are two examples:
AlteryxEngineCmd.exe MyWorkflow.yxmd
AlteryxEngineCmd.exe MyAnalyticApp.yxwz AppValues.xml
You can see a post here:
Alteryx Command Line Help
I prefer to wrap the command in a batch file and execute that for more control.
Now that you understand how to run the workflow from the command line, you can execute it anytime you want without launching Designer. Furthermore, you can use Windows Scheduler or a third-party tool to run the command or the batch file on a schedule.
Finally, you do need a license which enables API & Command Line w/ Scheduler. This is less expensive than Alteryx Server.
Have you tried C:\Program Files\Alteryx\bin\AlteryxEngineCmd.exe? It doesn't require server.
https://help.alteryx.com/2019.1/Command_Line.htm
If restrained by budget, you don't need a scheduler license (enables the AlteryxEnginecmd.exe), you can use a windows mouse clicker or even Powershell, to run the Designer though, without manual intervention.

TFS2015 vNext Build + PowerShell Customization -- Exception calling Save: TF215070: The build URI is not valid

Was previously using TFS2013 and XAML-based builds. Had created a number of custom tasks for the XAML builds in C#, including one to set the build number programmatically through the TFS .NET Client API libraries (not the REST API). Have now moved to TFS2015 and trying to move to vNext-based builds. Trying to convert our C#-based customizations to the new build process by re-coding as PowerShell scripts. I am trying to use the following script to programmatically set the build number (as we did previously via C#):
# Step 1: load the TFS assemblies
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Common")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client")
# Step 2: get the collection
$collection=[Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)
# Step 3: get the build server
$buildServer=$collection.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer])
# Step 4: get the details for the currently running build
$buildDetail = $buildServer.GetBuild($env:BUILD_BUILDURI)
# Step 5: update the build number
$buildDetail.BuildNumber = "1.2.3.4-MyBuild"
# Step 6: save the changes to the build details
$buildDetail.Save()
Everything seems to work just fine until step 6, when I try and save the change made to the buildDetail.BuildNumber. When the "Save()" method is called, the following error is generated:
Exception calling "Save" with "0" argument(s): "TF215070: The build URI vstfs:///Build/Build/40177 is not valid. Make sure that this build exists and has not been deleted.
As best I can tell, step 4 is returning an instance that implements the Microsoft.TeamFoundation.Build.Client.IBuildDetail interface (as I expected it would). Also, clearly the build URI is valid as it is specifically used to load the build information in that same step. Again, this logic mimics the same logic we use in our C#-based XAML customizations, just rewritten under PowerShell.
Searching the internet, I can find nothing related to this error and cannot figure out why I would be receiving it. I did find a (much more complex) version of what I am trying to do here: https://github.com/voice4net/build-scripts/blob/master/ApplyVersionFromSourceControl.ps1. While I haven't tried using this script directly, it appears to be doing basically the same thing and, presumably, worked for its author.
Is there anyone out there that can help me to understand this error, why I am getting it, and, ideally, how to fix it?
SIDE NOTE: This is not Microsoft's hosted TFS; this is a traditional TFS system that our company has installed internally.
It seems like you are trying to use the incorrect API to update your build number. You should be using the WebAPI/REST portion of the client DLLs.
That said I highly suggest you create a custom task in pure PowerShell or TypeScript in order to achieve your goal.
Here is an example of how to do so in TypeScript:
console.log(`##vso[build.updatebuildnumber]${newBuildNumber}`);
or in PowerShell:
Write-VstsUpdateBuildNumber -Value $newBuildNumber
You can check the reference here on how to create build tasks:
https://github.com/Microsoft/vsts-task-lib
The methods in the TFS SOAP object model (such as Microsoft.TeamFoundation.Build.Common) only apply to the XAML build system. You're targeting the wrong build system, which is why you're having problems.
Use the appropriate object model (either the REST APIs directly, or the C# REST API wrappers).

Creating VSCode Debugger Extension

I'm in the process of trying to write a VSCode extension to support basic SNES application development. I already have a basic grammar definition and build task, so I have syntax highlighting, and am able to build my project with Ctrl+Shift+B using the bass v14 assembler, but now I'm trying to figure out how to launch the project using launch.json. I've already worked through the official docs and played around with the mock debugger project, but I can't seem to figure out how to adapt it for my extension. To start, I'm using the bsnes-plus emulator as my debugger. There isn't really any command-line or IPC interface that will actually allow me to implement a proper debug adapter, so all I really want to do is to run the program and pass it my output file to launch. For the time being, I'm assuming that bsnes-plus.exe is located in my $PATH, but eventually I'll try and figure out the best practices for external executable dependencies for an extension.
So here are my current questions:
Is the "program" field of launch.json my compiled application, or is it bsnes-plus.exe?
If "program" is my application, where do I specify bsnes-plus.exe? Or vice versa.
Is there a way to specify my own project-level variables, e.g. $OUTPUT so that I don't have to hard-code the output filename into both the build task and the launch task?
At one point, I was able to get the launch command to open bsnes-plus, but not load the game, and when I closed it, VSCode complained that the debugger terminated unexpectedly and immediately re-opened bsnes-plus. How do I avoid this? Do I need to write a debug adapter even though it's not going to actually do anything other than launch the application, just so I can tell VSCode that it exited cleanly?
Is the "program" field of launch.json my compiled application, or is it bsnes-plus.exe?
This is entirely up to the debug extension. It's just passed through to the debug adapter. It usually corresponds to the specific app/script being debugged though, not the runtime that's running it, so I would suggest it should be your compiled application.
If "program" is my application, where do I specify bsnes-plus.exe? Or vice versa.
You can put it any other field. In Dart, we have a dartPath field that can be passed through to the debug adapter. It's usually populated silently by the DebugConfigurationProvider.resolveDebugConfig though (we detect the SDK by searching PATH) so the user never needs to add it.
Is there a way to specify my own project-level variables, e.g. $OUTPUT so that I don't have to hard-code the output filename into both the build task and the launch task?
You can't make your own variables, but using resolveDebugConfig you can manipulate the launch config yourself before it's passed to the debug adapter, which probably allows you to do what you need here (eg. you could do a string replace on program - or you could even just add it if it's not set, allowing a launch.json-less launch too).
Do I need to write a debug adapter even though it's not going to actually do anything other than launch the application, just so I can tell VSCode that it exited cleanly?
I'm not sure what happened here without more details, but having a debug adapter probably makes the most sense - for example if you want to make the Stop/Restart buttons work on the toolbar, you'd probably want a debug adapter that can terminate and/or restart the process.

Custom Action not being fired

Recently, I was assigned the task to create a deployment package for an application which btw, I'm totally new at. So far, so good.. Now there is a requirement to extract files from a zip file which will be bundled with the setup file. So, I had to write custom actions in the 'Commit' section of the Installer class. I added the Installer class in a new project of type 'Class Library' under the same solution. I wrote the code after 'base.Commit(savedState)'.
I tried showing MessageBox at the event entry point, used Debugger.Launch(), Debugger.Break() but somehow, no matter what I do, it seems that the custom action is not willing to be hit at all and the application just installs itself. I searched a lot of sites and blogs but no help so far.
I've assigned my installer class (SampleApp.exe, in my case) to all the Custom Action's modes (Install, Commit, Rollback and Uninstall) in the Deployment project. Any help.
P.S. I'm using a Visual Studio 2010 setup project.
Thanks, in advance!
You should probably be trying a class library Dll, not an executable (which is typically for something like a service).
You don't need it all the nodes if all you're doing is calling at Commit. And why Commit? Install is just the same in most cases.
If you're not seeing a MessageBox then probably your CA isn't being called, and that may because it's not a class library. Note that your CA is not running in the interactive user context - it's being called from an msiexec process running with the system account, so you must be very explicit about (say) the path to the zip file, and any user profile folders will probably fail because the system account doesn't really have them.
What files are these and where are they going on disk? If they are user profile files you can install the zip files to a per machine location and then have the application itself unzip the files to the desired location on first launch. Unzipping from within your setup is not good practice - it is error prone and bad design.
Using the application allows proper exception handling and interactivity (the user can be informed if something goes wrong). Set some registry flags in HKCU when you have completed the unzipping so it doesn't happen more than once, and perform the unzip once per user.

How to send REST request with build parameters in Jenkins Post Build Actions?

I am working on a CI system with Jenkins. But now I got a problem. I need to do the following steps.
1:Jenkins build
2:Deploy to Tomcat
3:find a way to send the build parameters (Job Name, build number...) to a web server (I am using REST now).
4:Web Server trigger testing system.
5:Jenkins get the result from testing system.
6:update build status
7:send emails.
I have problem with the step 3. I need to send those info after the deploy. I am thinking a way as following.
write those parameters to a file during build step, then call a script or Java problem to process the file and send out those info by REST.
But that is ugly. Is there any better ways to do it?
Side questions
Can groovy do this?
How to import groovy http-builder library to Jenkins?
I found a walk around solution.
1: ran echo command during the build to get the build ID and print to log.
2:wrote a small Java program to get the JSON response of the build then sent the necessary info as rest request to the server you set. The program is like a message forwarder.
3:in post build actions, use groovy post build to fetch the log then call the Java program.