I want to write a Visual Studio macro that switches off optimisations for a given C++ project. Does anyone have sample code to alter a project setting? And assuming that project settings are exposed as some sort of dictionary of values, what are the keys and value values for a project's C++ and Linker optimisations?
How to create a VS2008 macro to alter C++ project settings?
606 views Asked by mackenir At
2
There are 2 answers
0
On
Modified code from @mackenir 's Answer - for current project:
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Imports System.Text
Imports Microsoft.VisualStudio.VCProjectEngine
' Add Reference to Microsoft.VisualStudio.VCProjectEngine: Project > Add Refrence
Public Module Build
Sub CheckBuild()
Dim Prj As Object = DTE.ActiveSolutionProjects(0).Object
If Prj Is Nothing Then Return
Dim VPrj As VCProject = CType(Prj, Microsoft.VisualStudio.VCProjectEngine.VCProject)
If VPrj Is Nothing Then Return
Dim Cfg As VCConfiguration = CType(VPrj.Configurations.Item("Debug|x64"), Microsoft.VisualStudio.VCProjectEngine.VCConfiguration)
If Cfg Is Nothing Then Return
Dim CTool As VCCLCompilerTool = CType(Cfg.Tools("VCCLCompilerTool"), Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool)
If CTool Is Nothing Then Return
Dim LTool As VCLinkerTool = CType(Cfg.Tools("VCLinkerTool"), Microsoft.VisualStudio.VCProjectEngine.VCLinkerTool)
If LTool Is Nothing Then Return
CTool.DebugInformationFormat = debugOption.debugDisabled
LTool.GenerateDebugInformation = "false"
LTool.OptimizeReferences = optRefType.optNoReferences
LTool.EnableCOMDATFolding = optFoldingType.optNoFolding
ExecuteCommand("Build.BuildSelection")
End Sub
Visual C++ Project Model:
http://msdn.microsoft.com/en-us/library/2eydyk57.aspx
Some hacked-together macro code: