How do I add a Project Reference In SCSF Using GAT?

Jun 21, 2007 at 9:25 PM
I've added my own project templates to the SCSF Guidance Automation (June 2007 release). One of my project template needs a project reference to another dependent project. In the example below I want to add a project reference to "Infragistics.CompositeUI.WinForms" project.

Can someone explain to me how to add a project reference when using Guidance Automation Tookit?

I defined the following elements in my .vstemplate file but it doesn't work:

<ItemGroup>
<ProjectReference Include="$(SolutionDir)\Infrastructure\Infragistics.CompositeUI.WinForms\Infragistics.CompositeUI.WinForms.csproj">
<Project>{E9F028B3-3817-46FB-9324-EAAEF0DF5225}</Project>
<Name>Infragistics.CompositeUI.WinForms</Name>
</ProjectReference>
</ItemGroup>

Any tips would be greatly appreciated!
Developer
Jun 27, 2007 at 4:54 PM
Hi!

There are two ways to add a project reference using GAT:

  • The way you do it is one of those, why do you say it doesn’t work? The recipe fails or even the reference is not being added?
  • The other way to do it is by defining an action in the recipe for that purpose (Fortunately this action exists – see note below - so you don’t have to create a new one, only to use it). You can see the CreateSmartClientFactorySolutionCommon.xml‘s action section (under Recipes\Common folder).
Anyway, for your convenience I would include here the code:

Action code
<Action Name="AddInterfaceProjectReferenceToLibrary" Type="AddProjectReferenceAction" >
     <Input Name="ReferringProject" RecipeArgument="LibraryProject" />
     <Input Name="ReferencedProject" RecipeArgument="InterfaceProject" />
</Action>
As you see, the action requires two input parameters:
  • The referring project (the project where you want to add the reference)
  • The referenced project (the project you want to add as a reference in the referring project)

Note: The action’s type AddProjectReferenceAction is a type alias for Microsoft.Practices.RecipeFramework.Extensions.Actions.VisualStudio.AddProjectReferenceAction included in Microsoft.Practices.RecipeFramework.Extensions assembly. You can find this and others type alias in CommonTypeAliases.xml file (under Recipes\Common folder).

Here is the code that defines that alias:
<TypeAlias Name="AddProjectReferenceAction" 
Type="Microsoft.Practices.RecipeFramework.Extensions.Actions.VisualStudio.AddProjectReferenceAction, Microsoft.Practices.RecipeFramework.Extensions" />
It would be great if you could share the recipe you created (there is a codeplex project that hosts SCSF community’s contibutions).

Let me know if this helps,

Ezequiel Jadib
http://staff.southworks.net/blogs/ejadib
Jun 27, 2007 at 6:54 PM
Ezequiel

Thanks for taking time to answer my question. Actually the problem was very easy to solve. When I used the correct relative path to a project, all my references were added after the recipe was executed. For example:

Incorrect:
<ItemGroup>
<ProjectReference Include="$(SolutionDir)\Infrastructure\Infragistics.CompositeUI.WinForms\Infragistics.CompositeUI.WinForms.csproj">
<Project>{E9F028B3-3817-46FB-9324-EAAEF0DF5225}</Project>
<Name>Infragistics.CompositeUI.WinForms</Name>
</ProjectReference>
</ItemGroup>

Correct:
<ItemGroup>
<ProjectReference Include="..\..\Infrastructure\Infragistics.CompositeUI.WinForms\Infragistics.CompositeUI.WinForms.csproj">
<Project>{E9F028B3-3817-46FB-9324-EAAEF0DF5225}</Project>
<Name>Infragistics.CompositeUI.WinForms</Name>
</ProjectReference>
</ItemGroup>