1
我做這樣的:MSBUILD createproperty
<Target Name="CreateProperties">
<GetAssemblyFileVersionTask strFilePathAssemblyInfo="$(AssemblyInfo)">
<Output TaskParameter="strAssemblyFileVersion" PropertyName="strAssemblyFileVersion" />
</GetAssemblyFileVersionTask>
<Message Text="AssemblyFileVersion = $(strAssemblyFileVersion)" />
<CreateProperty
Value="$([System.Text.RegularExpressions.Regex]::Replace($(strAssemblyFileVersion), '^(\d+)\.(.+)\.\d+$', '$1_$2'))">
<Output
TaskParameter="Value"
PropertyName="rev" />
</CreateProperty>
<CreateProperty
Value="$(ProjName)">
<Output
TaskParameter="Value"
PropertyName="proj" />
</CreateProperty>
</Target>
當我運行的MSBuild我可以看到,無論轉速和凸出都在同一個文件的MSBuild目標CreateProperties和我的其他目標裏面活着。
但是....當我使用另一個在這個文件中importet的msbuild文件它就像他們不存在。合適的人是空的。任何想法爲什麼?
請注意,使用/ p定義的屬性是'global',不需要傳遞。創建的屬性(甚至全局屬性用CreateProperty重寫)仍然需要像通過一樣傳遞。這讓我感到頭痛。很好的答案! –