如何创建自定义的MSBuild任务时,你从C#代码当前项目目录? [英] How do you get the current project directory from C# code when creating a custom MSBuild task?

查看:331
本文介绍了如何创建自定义的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#代码当前项目目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆