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(“″)” “AssemblyVersion(“1.0.0.x”)” where x++ for every time the job in jenkins is being built.
Best Regards Jan

  • Jenkins always considers a build successful using batch/bat
  • git update submodule via windows batch file
  • How to use newline character in text in cmd batch?
  • Is there a way to force a commiter enter their username in git bash
  • Close cmd window after Git command in batch script
  • How to set correctly parameters to batch file to run “git pull”?
  • Can I organize Git submodules in a flat hierarchy?
  • Jenkins getting test results from docker slave
  • Running android emulator during jenkins build
  • VersionControlServer - Get latest version of file at a specific date/time
  • Jenkins pipeline - parallel stages merging only at the last stage
  • Pushing tags with Jenkins Git Publisher - multiple Git repositories (forks)
  • 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);

    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.


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