为什么不能在此AfterBuild目标中解决BaseOutputPath问题?

时间:2016-05-05 20:56:31

标签: properties msbuild

这是一个执行

副本的简单批处理文件

\ bin \ DEBUG或\ bin \ RELEASE -

它清理了nuget库拖动的一些垃圾。

但是,此属性$(BaseOutputPath)解析为空白。

<Target Name="AfterBuild">
  <!-- $(BaseOutputPath)\$(Configuration)\. doesn't work! -->
  <Exec Command="CALL postbuild.bat bin\$(Configuration)\" />
</Target>

所以有2个问题:

  1. 什么是正确的&#34;属性&#34;使用?
  2. 该属性应如何正确转义?

1 个答案:

答案 0 :(得分:2)

关于BaseOutputPath的文档声明&#39; 如果设置了它,MSBuild将使用OutputPath = $(BaseOutputPath)\ $(配置)\&#39;所以换句话说:如果你没有在项目文件中设置它(手动,它没有VS gui条目),它根本就没有定义。奇怪的是,如果我搜索MsBuild程序文件中的所有文件&#39;目录,在任何地方都找不到BaseOutputPath。所以也许它只用于我没有安装过的项目类型,或者它用在其他地方(不知道它会在哪里)。神秘但我现在没有时间搞清楚。 Microsoft.Common.CurrentVersion.targets有一些信息,你的回答是:

OutDir:
Indicates the final output location for the project or solution. When building a solution,
OutDir can be used to gather multiple project outputs in one location. In addition,
OutDir is included in AssemblySearchPaths used for resolving references.

OutputPath:
This property is usually specified in the project file and is used to initialize OutDir.
OutDir and OutputPath are distinguished for legacy reasons, and OutDir should be used if at all possible.

BaseIntermediateOutputPath:
This is the top level folder where all configuration specific intermediate output folders will be created.
Default value is obj\

IntermediateOutputPath:
This is the full intermediate Output Path, and is derived from BaseIntermediateOutputPath, if none specified
(eg. obj\debug). If this property is overridden, then setting BaseIntermediateOutputPath has no effect.

所以$(OutDir)在这里是正确的选择,或者$(outputPath)也会这样做。默认情况下,这些设置为bin\$(Configuration),以便完全符合您的要求。