用資源管理器右鍵編譯 Visual Studio 解決方案文件

 

每次改動 VC 工程之後都要重新編譯,每次 VS 又會生成調試數據庫文件,很費時間,於是研究了一下如何在資源管理器中直接編譯,還真發現瞭解決辦法。

 

以下是適用 Visual Studio 2008 的註冊表文件,導入系統之後右鍵點 .sln 文件就會出來編譯的菜單了:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell]

[HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Build Debug]
@="使用 VCBuild 編譯 Debug(&D)"

[HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Build Debug\Command]
@="cmd.exe /K \"\"C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\vcpackages\\vcbuild.exe\" \"%1\" \"Debug|Win32\"\""

[HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Bulild Release]
@="使用 VCBuild 編譯 Release(&R)"

[HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Bulild Release\Command]
@="cmd.exe /K \"\"C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\vcpackages\\vcbuild.exe\" \"%1\" \"Release|Win32\"\""


自 Visual Studio 2010 開始,微軟使用 MSBuild 取代了 Visual C++ 的 VCBuild,所以方法有些不同:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell]

[HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Build Debug]
@="使用 MSBuild 編譯 Debug(&D)"

[HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Build Debug\Command]
@="cmd.exe /K \"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe /m \"%1\" /p:Configuration=Debug /t:Build\""

[HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Bulild Release]
@="使用 MSBuild 編譯 Release(&R)"

[HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Bulild Release\Command]
@="cmd.exe /K \"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe /m \"%1\" /p:Configuration=Release /t:Build\""

 


注意:使用 MSBuild 的時候會檢查環境變量“Platform”,如果不確定配置的是否正確,建議刪除該環境變量即可(安裝完 Visual Studio 會默認該變量指爲 BNB,導致 MSBuild 無法正確編譯,但若啓動 Visual Studio IDE 來編譯則不會存在此問題)。

 

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章