MSBuild 无法解析导入文件的正确路径
我遇到了 MSBuild 4.0 无法正确解析导入的 MSBuild 文件之一中的路径的问题。文件开头的 ProjectOne.csproj 导入 GenericProject.proj。
GenericProject.proj 然后在需要时继续导入 ProjectOne.settings 文件,通过如下结构的调用:
<Import Project="$(MSBuildProjectName).settings" />
我假设当导入被解析时,它会有一个类似路径:
/Project Root/Src/ProjectOne/ProjectOne.settings
但是当通过 MSBuild 运行 ProjectOne.csproj 时,我得到的路径为:
/Project Root/Targets/ProjectOne.settings
这没有意义,因为考虑到所有路径都假定与主项目相关,在本例中是 ProjectOne.csproj。
所以我想知道是否有人知道为什么会发生这种情况?
文件夹结构:
- 项目根目录
- 源代码
- ProjectOne
- ProjectOne.csproj
- ProjectOne.settings
- ProjectOne
- 目标
- GenericProject.proj
- 源代码
我认为这并不重要,但以防万一我运行的是 windows 7 x64
编辑: (1:45-11/7/2010)< /em> 我能够通过在 $(MSBuildProjectName)
前面添加 $(MSBuildProjectDirectory)
标记来解决问题,但我仍然不知道为什么会这样。首先就没有正确解决。
I'm having an issue with MSBuild 4.0 not resolving a path correctly in one of my imported MSBuild files. ProjectOne.csproj at the very beginning of the file imports GenericProject.proj.
GenericProject.proj then goes on to import the ProjectOne.settings file when it needs it via a call structured like:
<Import Project="$(MSBuildProjectName).settings" />
I had assumed that when the import was resolved it would have a path of something like:
/Project Root/Src/ProjectOne/ProjectOne.settings
But when running the ProjectOne.csproj through MSBuild I got a path of:
/Project Root/Targets/ProjectOne.settings
This doesn't make sense because considering all paths are suppose to be relative of the master project, in this case ProjectOne.csproj.
So I'm wondering if someone knows why this is happening?
Folder Structure:
- Project Root
- Src
- ProjectOne
- ProjectOne.csproj
- ProjectOne.settings
- ProjectOne
- Targets
- GenericProject.proj
- Src
I don't think this matters, but just in case I'm running windows 7 x64
Edit: (1:45-11/7/2010) I was able to solve the problem by adding the $(MSBuildProjectDirectory)
tag in front of $(MSBuildProjectName)
but I still don't know why it wasn't resolving correctly in the first place.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你从哪里得到这个想法的?
元素与导入文件相关。Where did you get that idea?
<Import>
elements are relative to the importing file.