【问题标题】:Visual Studio Publish MSdeploy $(SolutionDir)Visual Studio 发布 MSdeploy $(SolutionDir)
【发布时间】:2016-01-21 17:33:28
【问题描述】:

我在使用 MSDeploy 和 Visual Studio 的发布配置文件时遇到了烦人的问题。在我的项目中,我有一个属性组,我设置了一个项目以供以后参考。

<LocalBuildLocation>$(SolutionDir)WebSites\MyWebSite\</LocalBuildLocation>

不幸的是,Visual Studio 将从该属性中随机删除 $(SolutionDir) 字符串,我的构建将失败。我手动将其复制回来,一切顺利。

谁能想到为什么这个项目会不断地自行移除?

【问题讨论】:

    标签: visual-studio msbuild publish msdeploy


    【解决方案1】:

    来自MSDN: Using project properties in assembly and include directives

    $(SolutionDir) 等 Visual Studio 宏在 MSBuild 中不起作用。你 可以改用项目属性。

    使用$(ProjectDir)(更安全,项目级属性)或$(MSBuildProjectDirectory)(最安全,始终存在)

    【讨论】:

      【解决方案2】:

      请参阅:$(SolutionDir) MSBuild property incorrect when running Sandcastle Help File Builder via CMDgetting the value of $(ProjectDir), $(SolutionDir) in a vcproj file

      看起来$SolutionDir 确实(有时)可以与 MSBuild 一起使用,但前提是您是从解决方案文件构建的。大多数情况下,它与$ProjectDir 相同。

      但您不应该能够在 MSBuild 中使用它们。即使它们有时会起作用——它也不可靠。正如另一个答案所指出的那样:

      像 $(SolutionDir) 这样的 Visual Studio 宏在 MSBuild 中不起作用。你 可以改用项目属性。

      来源:Code Generation in a Build Process

      $(ProjectDir) 项目的目录(定义为驱动器+路径); 包括尾部反斜杠“\”。

      $(SolutionDir) 解决方案的目录(定义为驱动器+ 小路);包括尾部反斜杠“\”。

      注意:

      您可以在项目的“属性页”对话框中的任何位置使用这些宏 接受字符串的框。

      来源:Macros for Build Commands and Properties

      【讨论】:

      • 标记为答案,而另一个是第一个,这更深入,第二个链接到“用于构建命令和属性的宏”让我找到了我需要的东西!有趣的是 $(SolutionDir) 它在属性组中不一致,这是我使用它的方式。我会看看 $(MSBuildProjectDirectory) 是否成立并且构建不会删除它。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-11
      • 1970-01-01
      • 2013-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多