2010-02-01 28 views
4

我試圖用VS創建一些宏來優化我的工作。目前我有以下宏:Visual Studio:用一個宏清理並重建

Public Sub ReleaseBuild() 
    DTE.ExecuteCommand("Build.SolutionConfigurations", "Release") 
    DTE.ExecuteCommand("Build.RebuildSolution") 
End Sub 

Public Sub DebugBuild() 
    DTE.ExecuteCommand("Build.SolutionConfigurations", "Debug") 
    DTE.ExecuteCommand("Build.RebuildSolution") 
End Sub 

我想要的是在實際重建它之前清理解決方案。我所做的是:

Public Sub ReleaseBuild() 
    DTE.ExecuteCommand("Build.SolutionConfigurations", "Release") 
    DTE.ExecuteCommand("Build.CleanSolution") 
    DTE.ExecuteCommand("Build.RebuildSolution") 
End Sub 

Public Sub DebugBuild() 
    DTE.ExecuteCommand("Build.SolutionConfigurations", "Debug") 
    DTE.ExecuteCommand("Build.CleanSolution") 
    DTE.ExecuteCommand("Build.RebuildSolution") 
End Sub 

但我得到的錯誤波紋管:

alt text http://img23.imageshack.us/img23/2667/errorcb.png

我相信乾淨已經被重建之前,首先完成。我知道這可以通過運行兩個單獨的宏來完成,但我實際上只需點擊一下即可實現。

最好的問候,

基里爾

+2

已經rebuild命令做了清潔第一。 – 2010-02-01 13:48:57

+0

如何將您的問題標記爲答案? – 2010-02-02 11:53:04

回答

6

重建不乾淨的解決方案第一

我知道,有很多的項目時,從經驗,當我在一個項目中,並調用添加參數去的方法考慮到該方法中參數的數量,從第二個項目實施附加參數的方法經常顯示出錯誤!

使用

DTE.Solution.SolutionBuild.Clean(True) 
DTE.Solution.SolutionBuild.Build(True) 

DTE.ExecuteCommand("Build.CleanSolution") 
DTE.ExecuteCommand("Build.RebuildSolution")