visual studio 2010 conditional references

You should be able to do this with conditional constructs by editing the project file directly (VS IDE won’t do this for you).

For example, you might do something like this using the “Choose” element:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
    <PropertyGroup>
        <!-- ... --> 
    </PropertyGroup>
    <Choose>

        <When Condition=" '$(Configuration)'=='Debug' ">
            <ItemGroup>
                <ProjectReference Include="..\stuff\MyStuff.csproj">
                    <Project>{4c7bbe47-8d84-45d4-95f0-f640ba59563c}</Project>
                    <Name>MyStuff</Name>
                </ProjectReference>
            </ItemGroup>
        </When>

        <When Condition=" '$(Configuration)'=='Retail' ">
            <ItemGroup>
                <Reference Include="MyStuff.dll" />
            </ItemGroup>
        </When>

    </Choose>
    <!-- Rest of Project -->
</Project>

MSDN has more information about using conditional constructs.

Leave a Comment