什麼是Project Property Sheets?三個字:好東西。舉例說明:
假設有好幾個專案都有用到Boost C++ Library,一般會在Project Properties裡的C/C++ > General > Additional Include Directories,填上Boost的路徑。這樣該專案便能使用到boost的標頭檔。
麻煩來了,如果你有十個專案都用到Boost,同樣的動作需要做十次(以上)。更慘的是,如果Boost出新版,而你又很想要新版才有的功能,那麼又要重覆十次(以上)的動作...Orz
From Coder to Developer:DRY (Don't Repeat Yourself)
這個時候Property Sheets就派上用場了。到Visual Studio 2005/2008,View > Property Manager,打開Property Manager後,在你的專案上點選右鍵,選擇Add New Project Property Sheet...,給個名字,出現一個與Project Properties一模一樣的視窗。
在該視窗上設定好Additional Include Directories,存檔後,同目錄下就會出現一個副檔名為vsprops的檔案,就叫它using_boost.vsprops吧。
接下來只要到其它九個專案的Property Manager,點選Add Existing Property Sheet...,選擇using_boost.vsprops。再把原本的Additional Include Directories設定殺掉,這些專案就會用到using_boost.vsprops提供的設定。未來要變更Boost路徑或升級,只要更改using_boost.vsprops即可。
我也是看了Google Chrome source code,才知道有這麼好用的功能,唉~真是慚愧...Orz
沒有留言:
張貼留言