Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String NAnt属性转换为小写_String_Nant - Fatal编程技术网

String NAnt属性转换为小写

String NAnt属性转换为小写,string,nant,String,Nant,我想防止在nant脚本的参数中放置不正确的大小写 我想取x的值并将其转换为小写,我尝试使用 string::to-lower() 但是,希望有人能遇到这个问题并有一个简单的解决方案,这是行不通的 <?xml version="1.0" encoding="utf-8"?> <project name="test" Default="test" value="net-4.0" > <property name="x" value="default"

我想防止在nant脚本的参数中放置不正确的大小写

我想取x的值并将其转换为小写,我尝试使用

string::to-lower()
但是,希望有人能遇到这个问题并有一个简单的解决方案,这是行不通的

<?xml version="1.0" encoding="utf-8"?>
   <project name="test" Default="test" value="net-4.0" >

     <property name="x" value="default" unless="${property::exists('x')}"/>

     <target name="test">
       <echo message="${x}" />
     </target>
   </project>
这将产生输出

 Target framework: Microsoft .NET Framework 4.0
 Target(s) specified: test

 [property] Read-only property "x" cannot be overwritten.

 test:

 [echo] TEST

 BUILD SUCCEEDED - 0 non-fatal error(s), 1 warning(s)

 Total time: 0.1 seconds.

任何解决方案都将不胜感激

您提到的功能应该可以正常工作。查看语法拼写是否正确:

<echo message="${string::to-lower(x)}" />

当你说参数时,你指的是它的名称还是它的值?也就是说,您想确保
x
是小写,还是
test
(我假设后者)?如果我有以下nant脚本:


这样称呼它:

nant.exe -buildfile:nant.build test -D:x=TESTx
nant.exe -buildfile:nant.build test -D:X=TESTX
我收到以下答复:

Target framework: Microsoft .NET Framework 4.0
Target(s) specified: test

test:

     [echo] testx

BUILD SUCCEEDED
Total time: 0 seconds.

Target framework: Microsoft .NET Framework 4.0
Target(s) specified: test

test:

     [echo] default

BUILD SUCCEEDED
Total time: 0 seconds.
这就是你想要的吗

更新

我想这就是让你绊倒的原因:

Note: properties set on the command-line are always read-only.

(From)

您好,谢谢您的回复,string::to lower本身就可以工作,谢谢。我可能解释得不够好的问题是,如果参数x存在,请将其转换为小写。上面的代码以最简单的形式表示了这个问题。好吧,我不明白什么不起作用。如果希望
x
包含其自身的小写版本,可以执行以下操作:
nant.exe -buildfile:nant.build test -D:x=TESTx
nant.exe -buildfile:nant.build test -D:X=TESTX
Target framework: Microsoft .NET Framework 4.0
Target(s) specified: test

test:

     [echo] testx

BUILD SUCCEEDED
Total time: 0 seconds.

Target framework: Microsoft .NET Framework 4.0
Target(s) specified: test

test:

     [echo] default

BUILD SUCCEEDED
Total time: 0 seconds.
Note: properties set on the command-line are always read-only.