This project has moved and is read-only. For the latest updates, please go here.


CoreCompile is not called from the Build context menu


When loading a .pyproj in Visual Studio that defines a CoreCompile target, the Build, Rebuild and Clean items appear. Selecting the Build item doesn't appear to run the Build target. Instead it appears to run the SourceFilesProjectOutputGroup target, which doesn't really do anything. Selecting Rebuild does run the ReBuild target, which eventually runs the Build and CoreCompile targets.

This is with PTVS 2.1 RC with Visual Studio 2012 and Tools version 4.0.

file attachments


Zooba wrote Aug 20, 2014 at 5:02 PM

What it's doing is discovering that your project is up to date (note the very last line). We probably shouldn't be showing this output at all, but it is expected.

The main problem that you're running into is that we don't have any way to detect that you need to build again. Since Python typically has no output files, we have nothing to compare file times against. Unfortunately, we've also left the user with no way around this.

Since you presumably have files to build, here's an easy fix (we'll see about getting it into 2.1, but it seems unlikely at this stage):
  1. Open C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v1#.0\Python Tools\Microsoft.PythonTools.targets in a text editor
  2. Change line 212 (part of the BuiltProjectOutputGroupFast target) from:
    <AssignTargetPath RootFolder="$(QualifiedProjectHome)" Files="@(Compile);@(Content);$(MSBuildProjectFile)">
    <AssignTargetPath RootFolder="$(QualifiedProjectHome)" Files="@(Compile);@(Content);$(MSBuildProjectFile);@(Generated)">
  3. Reopen your Python project and add/select the output files from your build step.
  4. Press F4 to open the Properties pane.
  5. For Build Action, enter "Generated" (it won't appear in the list)
Now your project will be able to correctly detect whether it needs to run the build step again. If your build step doesn't actually have any output files, you can add this line to the AfterBuild target to create one:
<WriteLinesToFile Lines="$([System.DateTime]::Now)" File="lastbuild.time" Overwrite="true" />
If you don't want to edit the installed .targets file, you can copy the entire BuiltProjectOutputGroupFast target into your .pyproj (after the Import) and make the change there, though bear in mind that this may affect your project's compatibility with newer/older PTVS versions (on the other hand, it will make it work on other machines with the same PTVS version, so you'll have to decide based on your scenario).

I'll suggest making the change to our team, but we're already past the point of taking most bug fixes (we need to ship eventually :) ) so it's probably not likely to make it.

NicholasPierce wrote Aug 21, 2014 at 10:49 AM

I've got the CoreCompile and CoreClean targets in a .targets file that's imported into our .pyproj, so I just added a BuiltProjectOutputGroupFast target which builds a BuiltProjectOutputGroupFastOutput ItemGroup that includes the project file and (as we're using py2exe) the and .exes that we make.

This appears to work, and Build is only run if the source files have been updated.


Zooba wrote Aug 21, 2014 at 5:56 PM


Incidentally, if you published a py2exe targets file, we'd love to promote it or merge it into PTVS.

Zooba wrote Aug 21, 2014 at 5:56 PM

Oh, and I'm still looking into a potential fix for 2.1 for this, so we may break your new target sooner than expected :)

Zooba wrote Sep 4, 2014 at 12:26 AM

I just put a fix in for 2.1 that adds @(OutputFiles) and @(InputFiles) groups to our normal up-to-date check, so you can add items to these groups either as part of your project or in a target that is set to run before BuiltProjectOutputGroupFast.