I have a config.ps1 script which has a variable "$versionNumber = “1.0.0"”. I need enter the variable value of users choice and save the config.ps1 file. I need to do this task using Jenkins Parameter.
My config.ps1 script.
#------------------------------------------------ # Pack parameters used to create the .nupkg file. #------------------------------------------------ # Specify the Version Number to use for the NuGet package. If not specified, the version number of the assembly being packed will be used. # NuGet version number guidance: https://docs.nuget.org/docs/reference/versioning and the Semantic Versioning spec: http://semver.org/ # e.g. "" (use assembly's version), "1.2.3" (stable version), "1.2.3-alpha" (prerelease version). $versionNumber = "1.0.0" # Specify any Release Notes for this package. # These will only be included in the package if you have a .nuspec file for the project in the same directory as the project file. $releaseNotes = "" # Specify a specific Configuration and/or Platform to only create a NuGet package when building the project with this Configuration and/or Platform. # e.g. $configuration = "Release" # $platform = "AnyCPU" $configuration = "" $platform = ""
My approach-
Get-Content c:\config.ps1 | ForEach-Object { $_ -replace "$versionNumber = "1.0.0"", "$versionNumber = "$env:version_number" }