gpt4 book ai didi

msbuild - 在 PropertyGroup 中使用 MSBuild token 时出错

转载 作者:行者123 更新时间:2023-12-02 21:24:43 29 4
gpt4 key购买 nike

我正在尝试设置一些在 MSBuild 脚本中多次使用的属性。我有以下属性部分:

<PropertyGroup>
<BuildDependsOn>$(BuildDependsOn); MyAfterBuild </BuildDependsOn>
<SubstitutionsFilePath>$(ProjectDir)app.config.substitutions.xml </SubstitutionsFilePath>
<AppConfig>$(TargetPath).config</AppConfig>
<HostConfig>$(TargetDir)$(TargetName).vshost.exe.config</HostConfig>
</PropertyGroup>

当我运行此程序时,出现以下错误:

The expression "@(TargetPath).config" cannot be used in this context. Item lists cannot be concatenated with other strings where an item list is expected. Use a semicolon to separate multiple item lists.

我不明白这个错误,因为使用 $(BuildDependsOn)$(ProjectDir) 工作正常。我知道 $(TargetXXX) 值会正确生成,因为当我将它们直接放入下面的任务部分时,它们工作得很好。

最佳答案

出现此问题的原因是 TargetDir 被定义为项目列表,而不是属性;大概是为了满足您的输出分布在多个输出目录中的情况?

我遇到了同样的问题,并设法通过使用 $(OutDir) 属性而不是 $(TargetDir) 来解决该问题。

(OutDir 属性在 Microsoft.Common.Targets(第 100-102 行)中定义为定义的 OutputPath 的规范化版本在您的项目文件中。)

关于msbuild - 在 PropertyGroup 中使用 MSBuild token 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1298833/

29 4 0
文章推荐: angular - 未知选项 : '--service-worker' creating new angular pwa
文章推荐: javascript - React -