Automatic Compilation with Resource modification
I am using Visual Studio 2008. Is it possible to perform automatic build of a solution whereby you are able to change the resource file/other files for the project to take the values into?
For example, expiry date. Each time I need a new expiry date, I will have to open up the solution, open the relevant source file, modify the expiry date, rebuild.
I wou开发者_JAVA技巧ld like to know if its possible to cut short all those steps and basically, just change the date and build without having to open the project at all.
Thanks!
You can run the build from the commandline without starting Visual Studio.
This together with a build script is the normal way to do time/dated builds
Examples:
devenv /clean release /project ProjectName SolutionName.sln
devenv /build release /project ProjectName SolutionName.sln
changes to a .rc file weren't always picked up by a /build in VS2005/8 so it's safer to do a clean build.
Then I have a python script that updates a version.h file containing
#define VERSION_MAJOR 1
#define VERSION_MINOR 12
#define VERSION_BUILD 368
#define VERSION_DATE "2010:06:19"
This is then included in a application.rc2 file. Sorry can't remember the reason for the convoluted string macro steps. I found it somehwere on the net years ago, there might be easier ways now - but this has worked from VC++6 to VS2010!
#include "version.h"
#define _STR(x) #x
#define STR(x) _STR(x)
#define VERSION_STRING STR(VERSION_MAJOR) "." STR(VERSION_MINOR) ".0." STR(VERSION_BUILD)
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION_MAJOR,VERSION_MINOR,0,VERSION_BUILD
PRODUCTVERSION VERSION_MAJOR,VERSION_MINOR,0,VERSION_BUILD
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080904b0"
BEGIN
VALUE "FileDescription", "XXX Application"
VALUE "FileVersion", VERSION_STRING "\0"
VALUE "InternalName", "XXX"
VALUE "LegalCopyright", "Copyright (C) 2010"
VALUE "LegalTrademarks", "XXX"
VALUE "ProductName", "XXX Application"
VALUE "ProductVersion", VERSION_STRING "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x809, 1200
END
END
Which is finally included in the application.rc
#include "res\application.rc2" // non-Microsoft Visual C++ edited resources
All this proved necessary because Visual Studio would overwrite external changes to the .rc file when it was opened in the dialog editor - don't know if this has been fixed in newer versions, and it's onyl a problem for MFC.
精彩评论