2016-05-05 28 views
0

這是執行一個副本爲什麼BaseOutputPath不會在這個AfterBuild目標中解析?

\ Bin \ Debug或\ BIN \發佈一個簡單的批處理文件 -

,並清理一些垃圾的的NuGet庫拖到一起。

但是,此屬性$(BaseOutputPath)解析爲空白。

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

所以2個問題:

  1. 什麼是正確的 「屬性」 使用?
  2. 該屬性應該如何正確轉義?
+0

'$(BaseOutputPath)'是正確的語法,但文檔會說'* if * it set',這可能意味着如果你沒有設置它,它就不存在了(並且與你的觀察結果相匹配)。我假設這是一個C#項目,所以我會去'$(OutputPath)',它通常已經包含$(Configuration)和$(Platform)。 – stijn

+1

這是一個答案!移動該評論來回答,以便我可以將其標記爲正確。 – MatthewMartin

回答

2

上BaseOutputPath狀態的文檔「如果它被設置,MSBuild的將使用OutputPath = $(BaseOutputPath)\ $(配置)\」,換句話說這樣:如果你不將其設置在項目文件(手動,沒有VS gui條目),它根本沒有定義。奇怪的是,如果我搜索MsBuild程序文件目錄中的所有文件,就不會找到任何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),這正是你想要的。

相關問題