Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Build Event Macros - Solution Configuration Name

In my Post-build event I call a batch file and pass it the current build config.

C:\Dev\Project\Build\build.bat /$(Configuration)

This passes the Project configuration name to the build script.

Is there anyway to pass the current Solution configuration name?

like image 508
misteraidan Avatar asked Jan 07 '11 04:01

misteraidan


2 Answers

Not directly. When you use Edit/Macros on a property field, the only configuration name listed is the one for the project that you already have.

You can, however, define your own macro. For each solution configuration, create a new property sheet, use the "User Macros" tab to define a macro whose name is "SolutionConfiguration" and whose value is the name of the configuration, then add this property sheet to the appropriate project configuration of every project in the solution.

If there's a better way I'd love to learn of it.

like image 168
Brangdon Avatar answered Oct 09 '22 07:10

Brangdon


I created a VS2010 extension for this, it lets you use $(SolutionConfiguration) and $(SolutionPlaform). $(BuildMacro) build macros. You can download the source and build it yourself from here.

Showing some code, it's just about registering to UpdateSolution_Begin method of IVsUpdateSolutionEvents VS and setting some Environment.SetEnvironmentVariable() there.

        _IVsSolutionBuildManager = (IVsSolutionBuildManager)GetService<SVsSolutionBuildManager>();
        _UpdateSolutionEvents = new UpdateSolutionEvents(); // IVsUpdateSolutionEvents
        int hr;
        uint pdwCookie;
        hr = _IVsSolutionBuildManager.AdviseUpdateSolutionEvents(_UpdateSolutionEvents, out pdwCookie);
like image 28
ceztko Avatar answered Oct 09 '22 05:10

ceztko