Return to site

How to write powershell script

broken image

# Make sure path to source code directory is available Write-Host '$Env:BUILD_BUILDNUMBER - For example, enter something like:' Write-Host '$Env:BUILD_SOURCESDIRECTORY = 'C:\code\FabrikamTFVC\HelloWorld'' Write-Host '$Env:BUILD_SOURCESDIRECTORY - For example, enter something like:' Write-Error 'to test this script interactively.' Write-Error 'You must set the following environment variables' If(-not ($Env:BUILD_SOURCESDIRECTORY -and $Env:BUILD_BUILDNUMBER)) # set environment variables so that this script can be debugged # If this script is not running on a build server, remind user to # Regular expression pattern to find the version in the build number # This script would then apply version 2013.07.19.1 to your assemblies. # then your build numbers come out like this: # $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev.r) # For example, if the 'Build number format' build pipeline parameter # If found use it to version the assemblies. To customize your build number in a classic pipeline, first add the build task to your pipeline. pwsh: echo $(Build.BuildNumber) //output updated build number name: $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev.r) You can customize your build number within a YAML pipeline with the name property.

broken image