在 Visual Studio 中获取预构建事件命令行的活动解决方案配置名称

Get active solution configuration name for pre-build event command line in Visual Studio

我的解决方案中几乎没有配置,我想在构建事件之前复制文件 app.{my-own-configuration-name}.config .

我知道变量 $(Configuration),但是这个变量只包含 DebugRelease 名称,而不是我的解决方案配置名称。我怎样才能做到这一点?

The command "xcopy /Y "C:\xxx\config\App.Debug.config" "C:\xxx\App.config"" exited with code 2.

这应该复制 App.Dev.config,而不是 App.Debug.config

您可能想查看 Slow Cheetah。它将有助于将配置文件转换为构建配置。

查看您的复制命令,C:\...\ 是无效路径。也许您需要 $(SolutionDir)?

尝试使用“$(ConfigurationName)”。

如果还是不行,你需要去Build > Configuration Manager,然后检查你的项目是否在这个配置下。