本文介紹了創(chuàng)建自定義 MSBuild 任務(wù)時如何從 C# 代碼中獲取當(dāng)前項(xiàng)目目錄?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我不想運(yùn)行硬編碼路徑的外部程序,而是想要獲取當(dāng)前的項(xiàng)目目錄.我正在使用自定義任務(wù)中的進(jìn)程調(diào)用外部程序.
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
這篇關(guān)于創(chuàng)建自定義 MSBuild 任務(wù)時如何從 C# 代碼中獲取當(dāng)前項(xiàng)目目錄?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!