本文介紹了創建自定義 MSBuild 任務時如何從 C# 代碼中獲取當前項目目錄?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我不想運行硬編碼路徑的外部程序,而是想要獲取當前的項目目錄.我正在使用自定義任務中的進程調用外部程序.
Instead of running an external program with its path hardcoded, I would like to get the current Project Dir. I'm calling an external program using a process in the custom task.
我該怎么做?AppDomain.CurrentDomain.BaseDirectory 只是給了我 VS 2008 的位置.
How would I do that? AppDomain.CurrentDomain.BaseDirectory just gives me the location of VS 2008.
推薦答案
你可以試試這兩種方法之一.
You can try one of this two methods.
string startupPath = System.IO.Directory.GetCurrentDirectory();
string startupPath = Environment.CurrentDirectory;
告訴我,你覺得哪個更好
Tell me, which one seems to you better
這篇關于創建自定義 MSBuild 任務時如何從 C# 代碼中獲取當前項目目錄?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!