Msbuild: "compile" context menu item for custom build action in Visual Studio 2010 (in a C ++ project)

I added a new build target for my Visual Studio Visual Studio project (vcxproj).
This goal launches its own tool when the project is built. The tool processes certain files in the solution according to the specified ContentType and ItemType types. This works well with projects like Build and Clean.

Now I would like to support the action equivalent to “compiling”, that is, right-clicking on a file in the solution explorer and choosing to process this specific file using my custom tool (just like “compile”, “CL” for “ C / C ++ File Types ").

I know I can add a Visual Studio macro for this. This is not a good solution for me, because for many users it is more complicated. The best solution is to configure vcxproj (or the files it imports).
I wonder if it is possible to add “compile” as an action in the menu (or change the “compilation” behavior for file types other than “C / C ++ Code”) using the msbuild or PropertyPageSchema task scripts.

UPDATE: I started a discussion on the MSDN forum. I received answers from a Microsoft moderator who helped me figure out some things, but the problem is still not resolved.


UPDATE (2016), for VS2015

AvailableItemNameseems to solve this on VS2015. For example, I have a custom purpose for processing Excel files.

In the goals file:

  <ItemGroup>
    <PropertyPageSchema Include="$(SolutionDir)\ExcelOptions.xml" />
  </ItemGroup>

  <ItemGroup>
    <AvailableItemName Include="Excel">
      <Targets>ProcessExcel</Targets>
    </AvailableItemName>
  </ItemGroup>

In the options file:

  <FileExtension Name=".xls"  ContentType="Excel"/>
  <ContentType   Name="Excel" DisplayName="Excel File" ItemType="Excel"/>
  <ItemType      Name="Excel" DisplayName="Excel File"/>

Now compilation is available in the context menu of Solution Explorer after selecting the excel file, and CTRL-F7 also works (for files that can be edited on VS and not for excel files)

+5
source share
1 answer

I have an AvailableItemName file in my goals file, but it still doesn't work. Could it be otherwise for vs2010? If so, does anyone know how to solve this problem in vs2010?

0

Source: https://habr.com/ru/post/1796609/


All Articles