Question

I'm trying to switch over from Aptana to PTVS but I'm stymied by an inability to configure the build process. I'd like to add a pre-build step that runs some tests and a post-build step that runs a zip packager / deployment script -- however I'm totally unable to figure out how to add these to PTVS.

In a C# project (for example) I could right click on the project file to get a configuration page which allows editing pre and post build targets. In PVTS that configuration page doesn't exist. My efforts to tweak the .pyproj file by hand have also be unsuccessful. I added a target tag (the way you would in, eg, c#) and was told that the element 'target' did not recognize the attribute 'name' - even though that's how it's specified in all the MS build configs I've ever seen elsewhere.

Is this possible? If so, how can I set it up?

Was it helpful?

Solution

It is not possible as of PTVS 2.0. It simply doesn't run any target on "build" (the fact that it shows "Building" in the Output window is really more of an artifact of VS, which has a mandatory build step for projects). That said, we have an outstanding feature request for this, and recognize the value of scripting various packaging and similar task through MSBuild.

We are not doing this exact thing for the upcoming 2.1 release, but there is something similar that might help you - since "building" does not actually make sense by itself for Python, we are instead allowing you to define commands in MSBuild that are exposed in Visual Studio UI on the project node in Solution Explorer; those commands can be backed by an arbitrary Python script. Have a look at these to see what this looks like (bearing in mind, of course, that this is an actively developed feature, and the code will probably change as we are working on it):

https://pytools.codeplex.com/SourceControl/latest#Python/Product/BuildTasks/Microsoft.PythonTools.targets https://pytools.codeplex.com/SourceControl/latest#Python/Product/Django/Microsoft.PythonTools.Django.targets

(search for <PythonCommand>)

We don't have a dev build that includes those changes yet to easily play with it, but we should get one out soon. You can, of course, just take the most recent sources and build them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top