c语言sscanf函数的用法是什么
227
2022-09-28
2019-11-6-Roslyn-how-to-use-WriteLinesToFile-to-write-the-semicolons-to-file
title | author | date | CreateTime | categories |
Roslyn how to use WriteLinesToFile to write the semicolons to file | lindexi | 2019-11-06 19:13:42 +0800 | 2018-11-1 16:9:1 +0800 | Roslyn MSBuild 编译器 |
As you know, the WriteLinesToFile will separate the item by semicolons. How can we use WriteLinesToFile to write the semicolons to file?
For example, we need to write the code below to file.
Console.WriteLine("I am lindexi");
As you can see, we can find some problems in the code.
The first thing is the code include quotation mark that we can not write the code directly.
We can use property item with "CDATA" that CDATA is defined as blocks of text that are not parsed by the parser.
You can find that your content in the file misses the semicolons character.
We can use %3b to replace the semicolons.
After you run the target, you can find a file named lindexi.cs added in your project.
Please open the file and then you can find the content in the file include the semicolons character.
We can set the property in the WriteLinesToFile task to Overwrite the file.
You can copy the code below to your project file and then run your project. You will see the console output something interesting.
I remove all your code and replace the code to the content in SomeThing property. And then I add the code that named lindexi.cs to compile.
Using MSBuild Escape
We can find this way should change the code. We can not copy the code in other to write to file and we should replace all the semicolons to %3b that is hard to change all the code.
We can use MSBuild Escape to escape the semicolons and you can see the code.
The [MSBuild]::Escape can use property function to escape strings.
How to: Escape Special Characters in MSBuild - Visual Studio
In the CDATA section that follows,
%40 =@%25 =% %3B =;%24 =$
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~