【问题标题】:Is there a way to override $(VCTargetsPath) from the project file?有没有办法从项目文件中覆盖 $(VCTargetsPath) ?
【发布时间】:2014-02-01 23:03:02
【问题描述】:

我需要使用 Microsoft Visual C++ 2010 和 MSBuild 为几个不同的平台构建我的软件。我将平台添加到 $(VCTargetsPath) 目录并创建了 .props 和 .targets 文件。然后我将文件复制到我的配置管理存储库,为复制的文件定义了一个到父目录的路径:$(CM_REPO_PATH),并希望重定向 Visual Studio 以使用存储库中的文件。

当我在我的机器上创建一个名为 %MSBuildExtensionsPath% 的环境变量并将其指向 $(CM_REPO_PATH)\MSBuild 时,我能够让项目工作。不过,我想要的是在 Visual Studio 项目中设置 $(VCTargetsPath) 和/或 $(MSBuildExtensionsPath),而不是在每个开发人员机器上的环境变量中。

当我添加属性组来执行​​此操作时...

<PropertyGroup>
  <VCTargetsPath>$(CM_REPO_PATH)\MSBuild\Microsoft.Cpp\v4.0</VCTargetsPath>
  <MSBuildExtensionsPath>$(CM_REPO_PATH)\MSBuild</MSBuildExtensionsPath>
  <MSBuildExtensionsPath32>$(CM_REPO_PATH)\MSBuild</MSBuildExtensionsPath32>
</PropertyGroup>

...新平台不可用(好像项目仍在使用默认的 $(VCTargetsPath),而不是指定的那个)。有没有办法覆盖项目文件中的 $(VCTargetsPath)?

【问题讨论】:

    标签: visual-studio visual-c++ msbuild projects-and-solutions


    【解决方案1】:

    您最初的声明是,您希望为多个不同的平台构建您的项目。

    https://docs.microsoft.com/en-us/visualstudio/extensibility/visual-cpp-project-extensibility?view=vs-2017 非常详细地描述了如何在 Visual Studio 2017 中实现这一点。希望您使用的版本也是如此。

    这样做的好处是,您根本不需要更改 $(VCTargetsPath)。

    【讨论】:

      猜你喜欢
      • 2021-02-02
      • 2014-07-18
      • 2018-10-05
      • 1970-01-01
      • 1970-01-01
      • 2017-05-16
      • 1970-01-01
      • 2015-04-18
      • 1970-01-01
      相关资源
      最近更新 更多