Write a batch script to edit text in a .cs file

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

  • Running MsTest in Jenkins fails with CreateProcess error=5, Access is denied
  • Show console output of a downstream job in upstream job
  • Setting up a Jenkins Pipeline build with parameters
  • Jacoco code coverage show 0% coverage on Jenkins
  • How to Run TestNG Tests on Jenkins
  • Jar not accepting values
  • CI with Maven, Git and Artifactory
  • Why can't this Powershell command be executed within Jenkins?
  • 2 Solutions collect form web for “Write a batch script to edit text in a .cs file”

    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);
    

    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

    Stay away from “batch-file automation” – will only cause you grief.
    (for a starter, different versions of Windows support a different set of batch-commands)

    You should incorporate the build-number in the script as an Environment Variable
    use either the “built-in” %BUILD_NUMBER% parameter or set your own format with
    the Formatted Version-Number Plugin .

    If you do need to edit that ‘CS’ file, I suggest using either Perl or PowerShell.

    Cheers

    Git Baby is a git and github fan, let's start git clone.