Retrieving Referenced Project's References RRS feed

  • Question

  • I am attempting Build Automation using the Dynamics CRM 2011 Developer Toolkit. The Dynamics CRM 2011 Developer Toolkit provides a Visual Studio 2010 Solution that includes a Visual Studio 2010 C# Class Library Project for the CRM Package to be deployed to the Dynamics CRM 2011 Server. A developer can also add one or more Class Library Projects for Dynamics CRM 2011 Plug-ins or Custom Workflow Activities (CWA).

    The CRM Package Project is modified by the Dynamics CRM 2011 Developer Toolkit to import a Target MSBuild Project and this Target MSBuild Project can therefore be further extended. I have extended this Target MSBuild Project by importing my own Target MSBuild Project, which I will talk about shortly.

    The challenge I am facing is that when a Plug-in or CWA project references other Projects or Assemblies, ILMerge is required to merge the Plug-in or CWA Project with its referenced Projects/Assemblies. To solve this challenge, I add every single Project or Assembly referenced by all Plug-in/CWA Projects in the Solution to the CRM Package Project as a reference.

    The idea is to only call ILMerge on the Plug-in/CWA Project and its references that are also referenced by the CRM Package Project. The challenge is to therefore determine which of the Plug-in/CWA Project references are also referenced by the CRM Package Project.

    I have created the following MSBuild file in an attempt to compare the references of a Plug-in/CWA Project to the references of the CRM Package Project:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <Target Name="FindReferences" Outputs="%(ProjectFiles.FullPath)">
        <CreateItem Include="@(ProjectReference)">
          <Output TaskParameter="Include" ItemName="ProjectFiles" />
        <CreateItem Include="@(Reference)">
          <Output TaskParameter="Include" ItemName="References" />
        <Message Text="Output Path: $(OutputPath)" Importance="high"/>
        <Message Text="Project References:" Importance="high"/>
        <Message Text="%(ProjectReference.FullPath)" Importance="high"/>
        <Message Text="Project Files:" Importance="high"/>
        <Message Text="%(ProjectFiles.FullPath)" Importance="high"/>
        <Message Text="Iterating through Project File References..." Importance="high"/>
        <MSBuild Projects="$(MSBuildProjectFile)" Properties="ProjectFile=%(ProjectFiles.FullPath)" Targets="GetReferences">
          <Output ItemName="ReferencedProjects" TaskParameter="TargetOutputs"/>
      <Import Project="$(ProjectFile)" Condition="$(ProjectFile)!=''"/>
      <Target Name="GetReferences" Outputs ="@(ReferencedProjects)" Condition="$(ProjectFile)!=''">
        <Message Text="Starting Iteration..." Importance="high"/>
        <Message Text="Removing Previous Referenced Projects..." Importance="high"/>
          <ReferencedProjects Remove="*"/>
        <Message Text="Adding Referenced Projects..." Importance="high"/>
        <CreateItem Include="@(Reference);@(ProjectReference)">
          <Output ItemName="ReferencedProjects" TaskParameter="Include"/>
        <Message Text="Referenced Projects for $(ProjectFile):" Importance="high"/>
        <Message Text="%(ReferencedProjects.FullPath)" Importance="high"/>
      <Target Name="AfterBuild" DependsOnTargets="FindReferences"/>
      <Target Name="AfterRebuild" DependsOnTargets="FindReferences"/>

    The problem I am having with the above MSBuild Target Project is that even though I remove all $(ReferencedProjects) before adding them from the current $(ProjectFile), the @(ProjectReference) of the $(MSBuildProjectFile) are always included.

    Is there a way for me to ensure that the @(ProjectReference) of the $(MSBuildProjectFile), i.e. the CRM Package, are excluded from the results of $(ReferencedProjects)?

    • Moved by Trevor HancockMicrosoft employee Wednesday, August 22, 2012 4:19 PM This had more to do with DCRM than MS or TFS Build. (From:Team Foundation Server - Build Automation)
    Monday, August 20, 2012 8:58 AM

All replies

  • Hi Johan,

    Thank you for your question.

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.
    Thank you for your understanding and support.

    Best Regards,

    Cathy Kong [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, August 21, 2012 8:07 AM
  • Thanks Cathy.
    Tuesday, August 21, 2012 9:51 AM
  • @Trevor - this is a MSBuild question, not a CRM Deployment question. Please move back to MSBuild/TFS Form.
    Wednesday, August 29, 2012 11:47 AM
  • did this thread go anywhere?  i'm having a similar problem
    Wednesday, August 29, 2012 9:47 PM