Checking if a Property 'Starts/Ends With' in a csproj
msbuild
Solution
An MSBuild property is just a .NET String and has property functions available.
Condition="$(Configuration.EndsWith('3.5'))"
Should work
Problem
I'm setting up some configurations in my csproj files that will target different framework versions. Ideally I want configurations of 'Debug - 3.5', 'Debug - 4.0', 'Release - 3.5' and 'Release - 4.0'. In my csproj file I want to do something like the following: ``` <PropertyGroup Condition=" '${Configuration}' ends with '3.5' "> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> </PropertyGroup <PropertyGroup Condition=" '${Configuration}' ends with '4.0' "> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> </PropertyGroup ... check for "starts with Debug" to define Optimize etc. ``` However, I don't know how to go about checking that `${Configuration}` starts/ends with a particular string. Is there an easy way to do this? Edit: Marked answer below for pointing me in the right direction, which lead me to go with: ``` <PropertyGroup Condition="$(Configuration.Contains('Debug'))"> ... setup pdb, optimize etc. </PropertyGroup> <PropertyGroup Condition="$(Configuration.Contains('3.5'))"> ... set target framework to 3.5 </PropertyGroup> ... and so on for Release and 4.0 variations ```