MSBuild task does not propagate Configuration property for referenced project assemblies

I have a solution with three projects, A, B, and CustomWrapper. A and B have a Debug, Retail, and a "Custom" configuration. The "Custom" configuration just has a different set of options (constants defined, assemblies referenced, optimation choices, etc).

B depends on A and has a ProjectReference to A as such:

<ItemGroup>
<ProjectReference Include="..\A\A.csproj">
<Project>{2AE75F5A-CD1F-4925-9647-AF4D1C282FB4}</Project>
<Name>A</Name>
</ProjectReference>
</ItemGroup>

CustomWrapper is a project that should build the "Custom" configuration of A and B, independent of what configuration is currently selected for the solution in VS. I tried to achieve this by writing an MSBuild task by hand in Wrapper.proj as such:

<ItemGroup>
<ProjectReferences Include="..\A\A.csproj" />
<ProjectReferences Include="..\B\B.csproj" />
</ItemGroup>
<Target Name="BuildCustomConfiguration">
<MSBuild Projects="@(ProjectReferences)" Properties="Configuration=Custom" Targets="Build">
<Output TaskParameter="TargetOutputs" ItemName="CustomAssemblies" />
</MSBuild>
</Target>

When I compile the CustomWrapper project, bin\Custom\A.dll builds just fine. However, the problem I am running into is that bin\Custom\B.dll references bin\Debug\A.dll (assuming that the Debug configuration is selected in VS) instead of bin\Custom\A.dll. All other options are correctly passed in to B.csproj.

How can I get bin\Custom\B.dll to reference bin\Custom\A.dll?

[1833 byte] By [ShriBorde] at [2007-12-24]
# 1
I don't know if this works for you but,

  1. What happens when you have a "custom" configuration for the solution from within VS? Are the references resolved correctly? They should as long as the Solution Configuration Properties are set correctly (i.e., the Debug configuration of the solution, has all the projects included in their Debug configuration, and so on).
  2. If 1 works out, you should be able to reproduce the results on command line with:
>> msbuild mysolution.sln Configuration="Custom"

When ever you want to build the custom configuration, just select that configuration in VS.

AdrigoGallus at 2007-8-31 > top of Msdn Tech,Visual Studio,Visual Studio MSBuild...

Visual Studio

Site Classified