locked
Custom Rules Files Don't Convert

    Question

  • I have a large number of Visual C++ build projects that have assembler code support using the YASM assembler with a yasm.rules file. 

    When I convert these projects in the Visual Studio 2010 beta, they all fail and this seems to be the result of a failure to recognide the yasm.rules file.  I have copied this file into the right place inn the 2010 installation (alongside masm.rules etc.) but it does not get picked up - the conversion log refers to a yasm.targets file but no such file is used in the VS 2008 VC++ environment.  

    I would be most grateful form advice on what I have to do to get the 2010 VC++ build system to accept my yasm.rules file.

       regards to all,

        Brian Gladman
    Saturday, May 23, 2009 9:55 AM

Answers

  • The format has changed in VS2010 beta 1. When I converted my project, the .rules file was converted along with it to several files. I can't access the partition right now, but I think it turned into a .vsrules file, a .targets file, and a .xml file. The best way for you to convert the file is just make a project that uses it and convert the project. Unfortunately, there doesn't seem to be an editor for the new format yet in beta 1, which makes modifying the rules files a manual affair.

    After you get the rules file converted and hooked up, you may run into the problem I did where they build but don't link into the output. To fix this, you'll need to look at the MASM.targets file included with VS2010 and copy over its ComputeLinkInputsTargets section and subtarget that it uses, renaming MASM to YASM. You'll also need to clone that section and rename the clone to ComputeLibInputsTargets to get the custom rule to work in a static library (filed as 456616 and 456624).
    • Marked as answer by BRG Thursday, May 28, 2009 6:39 AM
    Monday, May 25, 2009 12:58 AM

All replies

  • The format has changed in VS2010 beta 1. When I converted my project, the .rules file was converted along with it to several files. I can't access the partition right now, but I think it turned into a .vsrules file, a .targets file, and a .xml file. The best way for you to convert the file is just make a project that uses it and convert the project. Unfortunately, there doesn't seem to be an editor for the new format yet in beta 1, which makes modifying the rules files a manual affair.

    After you get the rules file converted and hooked up, you may run into the problem I did where they build but don't link into the output. To fix this, you'll need to look at the MASM.targets file included with VS2010 and copy over its ComputeLinkInputsTargets section and subtarget that it uses, renaming MASM to YASM. You'll also need to clone that section and rename the clone to ComputeLibInputsTargets to get the custom rule to work in a static library (filed as 456616 and 456624).
    • Marked as answer by BRG Thursday, May 28, 2009 6:39 AM
    Monday, May 25, 2009 12:58 AM
  • Thankyou for your advice, which I much appreciate.  I have put my rules file in the VC\VCProjectDefaults section with the Visual Studio install directory and it may be the read only property of this directory in non admin mode that prevented conversion.

        Brian
    Monday, May 25, 2009 6:43 AM
  • Thankyou again for your advice, which has got me a lot closer to success.  THe main problem was having my rules file in the VC install directory where the converted files were not written. 

    But I now get an error when I attempt to build:

      1>Error: Could not find an "AvailableItemName" item for the item type "YASM".

    Sadly, adding:

      <

     

     

    ItemGroup>
        <
    AvailableItemName Include="YASM" />
      </
    ItemGroup>

    into the targets file doesn't solve the problem.

          Brian
    Monday, May 25, 2009 8:28 AM
  • Not sure about that one. I don't have an AvailableItemName property in any of my rules files.

    Here is the original YASM.rules file that I used in VS2005 SP1 and the modified working version for VS2010 beta 1:
    http://www.virtualdub.org/external/YASM-custom-rules-VS2010.zip

    Monday, May 25, 2009 9:16 PM
  • Thanks for the YASM files for 2010, which get me a lot closer to a solution.  I still have one unresolved symbol (wmain) but I think this is caused by something else since the link step now sees my yasm obj files with your versions.

    The "AvailableItemName" issue still occurs though - this happens when I try to assemble a yasm *.asm file by right clicking on it (i.e assembly of one file rather than a full build)

    I can remove this by adding an "AvailableItemName" definition to the IDE build project (the *.vcxproj file) but I then get an error saying that there is no target for a selective build: 

    1>Error: No targets found for item type "YASM" for performing Selective Build Operation.


    This also happens for MASM so, as you found, it seems that this aspect of the 2010 beta appears to be largely untested.

    But I should now be able to find out why my yasm conversion files don't work (I need these as they give a lot more control over YASM than the ones you are using).

    In the meantime I have reported my problems as a bug.

    Thanks again for your help, which I much appreciate.

        Brian
    Monday, May 25, 2009 10:03 PM
  • Some background on our Custom Build Rules support in Dev10: During upgrade, VC will convert Custom Build Rules to MSBuild and generate 3 new files: CBR.targets (that contain the wiring of the CBR to the build system), CBR.props (that will contain all the default values for your CBR) and CBR.xml (that contains the MSBuild task definition). The xml file is used also by the Property Pages system to render each of the properties exposed by the CBR (similar to previous versions). CBRs are just a subset of the build customizations that the Dev10 C++ build system supports - you can import a generic <name>.targets/<name>.props in your project and this build customization can have any MSBuild implementation, not necesarily in CBR format (to add, right click on the project > Build Customizations... > Find Existing...)

    Some limitations:
    -- CBR Single/Selected files builds are not supported in Beta 1 but this will be fixed for Beta 2. There are some additional targets that need to be wired in the CBR.targets file (i.e. "Select<CBRName>" implemented similarly with "SelectClCompile").

    -- In Dev10 we're not planning to introduce a new Custom Build Rules editor. We're are planning on offering a good editing experience in the XML editor for the .targets/.props and the .xml file but the modal-dialog editing experience from VS2005/2008 will not be available anymore.

    @BRG: did your version of YASM.rules successfully converted after moving it out of $(VCInstallDir)? If not, can you make sure that you added to the bug report you opened?

    Thanks,
    Marian Luparu
    Visual C++

    PS: As you post on the forums, please also paste the links to the Connect bugs you opened such that other folks can vote on the issues you've found.
    Wednesday, May 27, 2009 4:04 AM
  • -- In Dev10 we're not planning to introduce a new Custom Build Rules editor. We're are planning on offering a good editing experience in the XML editor for the .targets/.props and the .xml file but the modal-dialog editing experience from VS2005/2008 will not be available anymore.
    Ouch.

    Might I suggest at least making a starting template? Looking at the contents of those files, it'd be pretty rough to create a custom build rule from scratch. They're significantly more complex to write and debug than a makefile rule. I think I'd rather just create the rules first in VS2005 and upgrade them rather than trying to use the XML editor.


    Wednesday, May 27, 2009 6:04 AM
  • @BRG: did your version of YASM.rules successfully converted after moving it out of $(VCInstallDir)? If not, can you make sure that you added to the bug report you opened?

    Thanks,
    Marian Luparu
    Visual C++

    PS: As you post on the forums, please also paste the links to the Connect bugs you opened such that other folks can vote on the issues you've found.
    Thank you for this feedback, which I appreciate.  My Connect bug report on this issue is at:

    http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=457852

    When I moved my yasm.rules out of the VC++ install directory it converted to the three files you describe but it did not work for the reasons reported in the bug report.

         Brian

     
    Wednesday, May 27, 2009 6:46 AM
  • -- In Dev10 we're not planning to introduce a new Custom Build Rules editor. We're are planning on offering a good editing experience in the XML editor for the .targets/.props and the .xml file but the modal-dialog editing experience from VS2005/2008 will not be available anymore.
    Ouch.

    Might I suggest at least making a starting template? Looking at the contents of those files, it'd be pretty rough to create a custom build rule from scratch. They're significantly more complex to write and debug than a makefile rule. I think I'd rather just create the rules first in VS2005 and upgrade them rather than trying to use the XML editor.



    I second this suggestion.  I tried to produce an msbuild solution to solve this problem but found it very difficult since many of the things needed in the xml files are not well documented in the on-line msbuild documentation.    We hence need fully documented example templates for all the files that are needed to integrate an external build tool such as an assembler into Dev10. 

    In fact assemblers such as YASM and NASM are widely used in place of MASM so it would make sense to publish a set of custom build files for these assemblers.

         Brian
    Wednesday, May 27, 2009 6:53 AM