问题描述
调查只发生在我们的构建服务器上的构建问题,我很惊讶地看到这个答案指出有$(ProjectDir)
和 $(MSBuildProjectDir)
,前者有时不可用.
Investigating a build problem that only occurs on our build server, I was surprised to see this answer point out there is both a $(ProjectDir)
and a $(MSBuildProjectDir)
, the former sometimes not available.
大体上有什么区别?如果可用,我是否应该始终使用 $(MSBuildXXX)
版本的属性?为什么首先要使用 $(ProjectDir)
?
What is the difference in general? Should I always be using $(MSBuildXXX)
versions of properties if available? Why use $(ProjectDir)
in the first place?
与其他问答中的建议相反,我有时会看到 $(MSBuildProjectDir) = ''
.
Contrary to advice in the other Q&A, I'm sometimes seeing $(MSBuildProjectDir) = ''
.
推荐答案
正如您链接的答案所说 $(ProjectDir)
仅在导入 Microsoft.Common.Targets 后可用,而 $(MSBuildProjectDir)
是 MSBuild 本身的保留属性.
As your linked answer says $(ProjectDir)
is only available after Microsoft.Common.Targets has been imported, while $(MSBuildProjectDir)
is a reserved property in MSBuild itself.
因此,使用 $(MSBuildXXX)
属性将确保您始终可以使用它们,而无需导入所有必要的引用.
So using the $(MSBuildXXX)
properties will ensure that they are always available to you without needing to import all the necessary references.
这篇关于$(ProjectDir) 和 $(MSBuildProjectDir) 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!