编写批处理脚本以编辑.cs文件中的文本 [英] Write a batch script to edit text in a .cs file

查看:188
本文介绍了编写批处理脚本以编辑.cs文件中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人知道如何编写批处理脚本来编辑.cs文件中的某些文本. 我想做的是更改"AssemblyVersion("1.0.0.0")" AssemblyVersion("1.0.0.x"),其中每次构建jenkins的工作时都使用x ++. 此致Jan

I wonder if anyone knows how to write a batch script to edit some text in a .cs file. What I want to do is change "AssemblyVersion("1.0.0.0")" "AssemblyVersion("1.0.0.x")" where x++ for every time the job in jenkins is being built. Best Regards Jan

推荐答案

是否要为此仅使用批处理脚本?您还可以使用 Execute Groovy脚本选项并编写一些简单的Groovy脚本来实现这一目标

Do you want to use only a batch script for this? You could also use Execute Groovy Script option and write some simple groovy script to achieve this

file = new File("folder/path/myfile.cs")
fileText = file.text;
fileText = fileText.replaceAll(srcExp, replaceText);
file.write(fileText);

您还可以使用jenkins作业中的availabe环境变量来构造替换文本.这些变量将出现在/env-vars.html

You can also use the availabe environment variables from your jenkins job to construct your replace text. These variables will be present at /env-vars.html

这篇关于编写批处理脚本以编辑.cs文件中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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