visual-studio - Visual Studio 变量可用于配置文件?

标签 visual-studio visual-studio-2013 environment-variables app-config

$(ProjectDir) 等不会在我的 Visual Studio C# 项目的 app.config 文件中被替换。

我确定这很简单,我只是在寻找错误的东西,但有人知道吗?

编辑:
我想在我的 app.config 中有这项工作:

<add key="path" value="$(ProjectDir)..\blabla">

最佳答案

诸如 $(ProjectDir) 之类的东西是在 Visual Studio 和 MSBuild 构建系统中使用的构建时(或更确切地说,设计时)环境变量。它们与您正在构建的应用程序无关。您的 app.config file 是程序的运行时配置文件。

如果您希望在构建项目时 app.config 文件中的文本有所不同,那么您应该查看 T4 模板:http://msdn.microsoft.com/en-us/library/bb126445.aspx - 您可以在其中使用 VS 的环境变量(请参阅“访问环境”下的 http://msdn.microsoft.com/en-us/library/vstudio/ee848143(v=vs.100).aspx)。

但是在您的情况下,您似乎可以在应用程序中使用相对路径,为什么需要在配置文件中对路径进行硬编码?

关于visual-studio - Visual Studio 变量可用于配置文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23908148/

相关文章:

c++ - Visual Studio 2013 C++ 监 window 口 : arrays copy incorrectly to clipboard

visual-studio-2015 - 如何从 Visual Studio 中的解决方案中卸载*所有* nuget 包

c++ - Visual Studio 2013 : Error MSB4014: The build was aborted because of an internal failure

java - 在哪里为在 glassfish 4 中运行的应用程序设置系统变量

c++ - dll 中的资源字符串在程序中加载后不完全可见

c++ - 多重定义结构错误

php - 如何在 PHP 中获取客户端 IP 地址

macos - 在 Mac OS X Lion 上设置环境变量

c++ - 我能否使 Visual Studio 2008 中的 C++ 表现得像早期版本一样?

git - Visual Studio 是否可以要求将工作项链接到 git 提交?