【问题标题】:[MSBUILD]-[Target]-[Import]-relative project path not working on build server[MSBUILD]-[Target]-[Import]-相对项目路径在构建服务器上不起作用
【发布时间】:2015-09-02 19:09:39
【问题描述】:

我正在尝试使用 .csproj 中的以下条目在源代码管理中的项目的相对位置使用目标

<Import Project="..\..\Shared\Build\Tools\Targets\config.transform.targets" Condition="Exists('..\..\Shared\Build\Tools\Targets\config.transform.targets')" />

以下路径中提到的共享文件夹比 .csproj 文件位置高两级,如 仪表板\共享\构建\工具\目标 Dashboard\Admin\ConfigurationConsole\ConfigurationConsole.csproj

本地项目和解决方案构建良好,但在构建服务器上排队时失败并出现以下错误。

TransformWebConfig 在项目中不存在。

所以在尝试了很多事情之后,当我最终将相对路径更改为下面的它时,它起作用了。

<Import Project="..\Shared\Build\Tools\Targets\config.transform.targets" Condition="Exists('..\Shared\Build\Tools\Targets\config.transform.targets')" />

想知道这里发生了什么,以及什么是可以在任何地方运行的合适解决方案。

【问题讨论】:

    标签: visual-studio-2013 msbuild


    【解决方案1】:

    实际上,指向相对路径的更好方法是使用 $(MSBuildProjectDirectory) 环境变量将当前路径强制为当前项目目录

    Relative paths with MSBuild project vs solution

    MSBuild: convert relative path in imported project to absolute path

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-30
      • 2015-08-18
      • 1970-01-01
      • 1970-01-01
      • 2021-10-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多