Ask a questionAsk a question
 

AnswerMacro for Solution Platform

  • Friday, October 30, 2009 11:24 PMMatt6781 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    I have a VS 2008 solution which contains several managed projects as well as one native project. Most of the managed projects are configured to build for any CPU. One of them is configured to build for either x86 or x64 because it depends on a native DLL that is also part of the solution.

    To this end, my solution has two platforms, Win32 and x64. Within these platforms I have used the configuration manager to specify the build configuration for the individual projects. Most of the projects still build for any CPU, except for the two that must be compiled for a particular architecture.

    So, I do four builds: x86/debug, x86/retail, x64/debug, x64/retail.

    Basically, I would like to specify that the any CPU targets go to the binary folder of the build being done. So even if a binary is compiled for any CPU I would like it to go to the binaries.x86.debug folder.

    And now my Q: $(Platform) gives the platform of the project, not the solution. Is there any way to get the solution platform that is selected (Win32/x64) so I can use that in macro form for my output directories.

    Thanks,
    Matt

Answers

  • Tuesday, November 03, 2009 7:56 AMNancy ShaoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi Matt,

     

    Please refer to Aaron Hallberg’ blog: Solution Configurations. As this article says:

     

    The platforms / configurations selected for the ConfigurationsToBuild item group really needed to be solution-level platforms / configurations. As following shows:  

      <ItemGroup>

        <ConfigurationToBuild Include="Debug|Mixed Platforms">

            <FlavorToBuild>Debug</FlavorToBuild>

            <PlatformToBuild>Mixed Platforms</PlatformToBuild>

        </ConfigurationToBuild>

      </ItemGroup>

    In Orcas, Team Build is much less tightly coupled with the building of solutions, so the platforms / configurations selected for the ConfigurationToBuild item group will depend on the contents of the SolutionToBuild item group.  That is, if SolutionToBuild items are in fact solutions, the ConfigurationToBuild item group should still specify solution-level platforms / configurations.  If, on the other hand, the SolutionToBuild item group contains projects, the ConfigurationToBuild item group should contain project-level platforms / configurations.

    In any case, behind the scenes Team Build will invoke MSBuild on each item in the SolutionToBuild item group once for each item in the ConfigurationToBuild item group, and will pass in values for the $(Platform) and $(Configuration) properties corresponding to the PlatformToBuild and FlavorToBuild values from the ConfigurationToBuild item group.

    So I think you can specify ConfigurationToBuild with your solution configuration and use $(platform) and $(Configuration) properties to get these solution related information. 

    Best Regards,

    Nancy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

All Replies

  • Monday, November 02, 2009 6:17 PMLeonid GanelineMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Matt,

    Do you want to do the conditional buids, I mean choosing one of four by parameter? Or do you want to create all four in one process?
    Or the platform should be choosen by current CPU?
    Anyway you could use the Conditional Constructs (when, choose). See http://msdn.microsoft.com/en-us/library/ms164307.aspx
    Please, Let me know if you need something else.
    Leonid Ganeline [BizTalk MVP] My BizTalk blog
  • Monday, November 02, 2009 6:31 PMMatt6781 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    My questions is a little different, basically, what I am trying to do is create output binary directories like the following:

    binaries.Win32.Debug
    binaries.Win32.Retail
    binaries.x64.Debug
    binaries.x64.Retail

    I would do this like: binaries.$(PlatformName).$(ConfigurationName)

    However, $(PlatformName) is the *project* platform, not the solution platform. So for many of the things I build this would equate to "Any CPU" - instead I would like to know what the *solution* platform is, either x64 or Win32.

    Does this make sense?

    Thanks,
    Matt
  • Monday, November 02, 2009 9:29 PMLeonid GanelineMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    My understanding is you have to use one more parameter, exactly the $(ProjectPlatform). In your logic it it is not the $(PlatformName). If the ProjectPlatform and PlatformName have some logical link, you need to explicitly define it.
    Leonid Ganeline [BizTalk MVP] My BizTalk blog
  • Tuesday, November 03, 2009 7:56 AMNancy ShaoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi Matt,

     

    Please refer to Aaron Hallberg’ blog: Solution Configurations. As this article says:

     

    The platforms / configurations selected for the ConfigurationsToBuild item group really needed to be solution-level platforms / configurations. As following shows:  

      <ItemGroup>

        <ConfigurationToBuild Include="Debug|Mixed Platforms">

            <FlavorToBuild>Debug</FlavorToBuild>

            <PlatformToBuild>Mixed Platforms</PlatformToBuild>

        </ConfigurationToBuild>

      </ItemGroup>

    In Orcas, Team Build is much less tightly coupled with the building of solutions, so the platforms / configurations selected for the ConfigurationToBuild item group will depend on the contents of the SolutionToBuild item group.  That is, if SolutionToBuild items are in fact solutions, the ConfigurationToBuild item group should still specify solution-level platforms / configurations.  If, on the other hand, the SolutionToBuild item group contains projects, the ConfigurationToBuild item group should contain project-level platforms / configurations.

    In any case, behind the scenes Team Build will invoke MSBuild on each item in the SolutionToBuild item group once for each item in the ConfigurationToBuild item group, and will pass in values for the $(Platform) and $(Configuration) properties corresponding to the PlatformToBuild and FlavorToBuild values from the ConfigurationToBuild item group.

    So I think you can specify ConfigurationToBuild with your solution configuration and use $(platform) and $(Configuration) properties to get these solution related information. 

    Best Regards,

    Nancy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.