Reputation: 9295
I have a project that needs to different versions of a few DLLs depending on the release configuration.
Usually I would do that the following way:
<Reference Condition=" '$(Configuration)|$(Platform)' == 'V16Release|AnyCPU' " Include="Microsoft.SharePoint.Client.Runtime, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.SharePointOnline.CSOM.16.1.5626.1200\lib\net45\Microsoft.SharePoint.Client.Runtime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Condition=" '$(Configuration)|$(Platform)' == 'V16Release|AnyCPU' " Include="Microsoft.SharePoint.Client.Runtime.Windows, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.SharePointOnline.CSOM.16.1.5626.1200\lib\net45\Microsoft.SharePoint.Client.Runtime.Windows.dll</HintPath>
<Private>True</Private>
</Reference>
and this for the other Build-configuration:
<Reference Condition=" '$(Configuration)|$(Platform)' == 'V15Release|AnyCPU' " Include="Microsoft.SharePoint.Client.Runtime, Version=15.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.SharePointOnline.CSOM.15.1.1626.1200\lib\net45\Microsoft.SharePoint.Client.Runtime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Condition=" '$(Configuration)|$(Platform)' == 'V15Release|AnyCPU' " Include="Microsoft.SharePoint.Client.Runtime.Windows, Version=15.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.SharePointOnline.CSOM.15.1.1626.1200\lib\net45\Microsoft.SharePoint.Client.Runtime.Windows.dll</HintPath>
<Private>True</Private>
</Reference>
As you can see, depending on the release configuration, different DLLs are loaded.
While this works, there are more than just two packages. So is there a way to group my conditions like:
<Group Condition=" '$(Configuration)|$(Platform)' == 'V15Release|AnyCPU' ">
<Reference.... />
<Reference.... />
<Reference.... />
<Reference.... />
</Group>
So just a simple "if (left==right) {}
" as you would write it in code?
Upvotes: 0
Views: 78
Reputation: 35901
If you edit the project in an editor you'll see References are in an ItemGroup so you can put a condition on that, and have multiple groups with different conditions:
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'V15Release|AnyCPU' ">
<Reference.... />
<Reference.... />
<Reference.... />
<Reference.... />
</ItemGroup >
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'V16Release|AnyCPU' ">
<Reference.... />
<Reference.... />
<Reference.... />
<Reference.... />
</ItemGroup >
Upvotes: 1