Skip to content

Instantly share code, notes, and snippets.

@FeodorFitsner
Created July 5, 2015 20:33
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FeodorFitsner/e038821e3e46e3df0e8f to your computer and use it in GitHub Desktop.
Save FeodorFitsner/e038821e3e46e3df0e8f to your computer and use it in GitHub Desktop.
Taking version from AssemblyInfo.cs and using it with AppVeyor
rem This is how we get version in environment variable
for /f %%i in ('PowerShell -File get-version.ps1') do set my_version=%%i
$directoryPath = Split-Path ((Get-Variable MyInvocation).Value).MyCommand.Path
$assemblyFile = "$directoryPath\VersionInfo.cs"
$RegularExpression = [regex] 'AssemblyVersion\(\"(.*)\"\)'
# Get the Content of the file and store it in the variable
$fileContent = Get-Content $assemblyFile
#$fileContent
foreach($content in $fileContent)
{
$match = [System.Text.RegularExpressions.Regex]::Match($content, $RegularExpression)
if($match.Success) {
$match.groups[1].value
}
}
@rbonestell
Copy link

Can you please elaborate on how to run the cmd and ps1 at the same time? It appears in my build settings that I only get to choose one script type and I'm already dependent upon nuget restore in cmd in my before build script.

@Mike-E-angelo
Copy link

Positively incredible that CI/CD has been "evolving" for nearly a decade and the simple matter of properly versioning artifacts remains frustratingly elusive. 🤦‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment