C#检查,如果物业在的csproj“开始/结束用' [英] C# Checking if a Property 'Starts/Ends With' in a csproj

查看:184
本文介绍了C#检查,如果物业在的csproj“开始/结束用'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的csproj文件将针对不同的framework版本设置一些配置。理想的情况是我想要的配置调试 - 3.5,调试 - 4.0,发布 - 3.5和发布 - 4.0。



在我的csproj文件,我想做类似如下:

 <的PropertyGroup条件= GT$ {配置}与3.5结束 ; 
< TargetFrameworkVersion>&V3.5 LT; / TargetFrameworkVersion>
< /的PropertyGroup
<的PropertyGroup条件= GT$ {}配置与4.0结束;
< TargetFrameworkVersion>&V4.0 LT; / TargetFrameworkVersion>
< /的PropertyGroup
...检查使用调试开始来定义优化等

不过,我不知道如何去检查 $ {配置} 启动/与特定的字符串结尾。有没有一种简单的方法来做到这一点。



修改:下面指着我在正确的方向,这导致我去有明显的答案

 <的PropertyGroup条件=$(Configuration.Contains('调试'))> 
...设置PDB,优化等
< /&的PropertyGroup GT;
<的PropertyGroup条件=$(Configuration.Contains('3.5'))>
...设定的目标框架3.5
< /&的PropertyGroup GT;
...等等的释放和4.0的变化


解决方案

这是MSBULD属性只是一个字符串净,具有静态属性功能可用。

 条件=$(Configuration.EndsWith('3.5'))

应工作


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

解决方案

An MSBULD property is just a net String and has static property functions available.

Condition="$(Configuration.EndsWith('3.5'))"

Should work

这篇关于C#检查,如果物业在的csproj“开始/结束用'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆