Automatically generate version information in a C/C++ project with Azure DevOps.
- Copy the Version.rc file to your project folder.
- Include the Version.rc file in the project (How to).
- Add the definitions to your resource.h file.
#define APP_NAME "AppName"
#define APP_FILE_NAME APP_NAME ".exe"
#define APP_COMPANY_NAME "Company Name"
#define APP_WEB_SITE "Web Site"
#define APP_COPYRIGHT "Copyright (C) " APP_COPYRIGHT_YEAR " Name"
#define APP_DESCRIPTION "Application Description"
- Add the compiler's preprocessor definitions (How to).
APP_VERSION="$(AppVersion)";APP_COPYRIGHT_YEAR="$([System.DateTime]::Now.Year.ToString())"
- Add the resource compiler's preprocessor definitions.
APP_VERSION=\"$(AppVersion)\";APP_VERSION_BINARY=$(AppVersion.Replace('.', ','));APP_COPYRIGHT_YEAR=\"$([System.DateTime]::Now.Year.ToString())\"
- Add the AppVersion property element to your project file (.vcxproj).
<PropertyGroup>
<AppVersion Condition="'$(AppVersion)' == ''">0.0</AppVersion>
</PropertyGroup>
Note: If you need to build your project with version number locally, you can set the environment variable $env:AppVersion="1.0"
in a PowerShell console, then open the solution from the console and build the project.
_tprintf(_T("\n%s %s - %s\n"), _T(APP_NAME), _T(APP_VERSION), _T(APP_DESCRIPTION));
_tprintf(_T("%s\n"), _T(APP_COPYRIGHT));
_tprintf(_T("%s\n\n"), _T(APP_WEB_SITE));
_tprintf(_T("Usage: %s <Arguments>\n\n"), _T(APP_FILE_NAME));