开发者

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 开发者_StackOverflow社区/$(Configuration)

This passes the Project configuration name to the build script.

Is there anyway to pass the current Solution configuration name?


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);


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.


There is property SolutionConfigurationContents witch is created by Msbulid during soluton file processing it contains solution configuration in it. When building from VS it will contains project (not solution) configuration.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜