简体   繁体   中英

MsBuild task and scope of properties

I have one build project with target build

<Target Name="Build">
    <Message Text="Version : $(FullVersionNr)"  />
    <MSBuild Projects="@(WebProj)"  Properties="WebProjectOutputDir=$(SitePublishPath);OutDir=$(SitePublishPath1);Configuration=$(Configuration)" />      
<Message Text="Version  : $(FullVersionNr)"  /> 

and during build I set $(FullVersionNr) to accurate assembly number and it's not this nr at the end

I even declared $(FullVersionNr) prop in another file

<Import Project="Common.proj"/>

and it's not getting out.

It's only one way communication from parent to child project, and I want it to be bi-directional

This MSDN article should give you a few ideas on how to achieve this: MSBuild Properties . More specifically, this blog post should answer your scope questions: Scope of properties and item in an MSBuild script . Be sure to read the summary at the end.

So if you are batching over multiple projects, it is possible that the local contexts have not been merged back into the global context when you access the $(FullVersionNr) for the second time, or that one local context has overwritten another (ie two child projects, the first updates the build, but the second doesn't).

One possible solution for you is to use registry properties as described in the MSDN article, and only write the property when its value is updated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM