MSBuild: Using CreateItem and CreateProperty#

A coworker just found a problem in our build scripts, our ItemGroups were not getting evaluated at the time they were actually used.  After a little digging my coworker found that ItemGroups and Properties are evaluated when the msbuild file loads.  So our issue was our ItemGroup referred to a directory structure that was not created until later in the msbuild file, so the ItemGroup was empty when evaluated.  To get the newly created directory structure and files use the CreateItem task.

Example:

  <!-- Evaluate the contents of the ClientPublishDir now -->
  <CreateItem Include="$(ClientPublishDir)\**\*">
   <Output TaskParameter="Include" ItemName="ClickOnceFiles"/>
  </CreateItem>

More on this here.

Friday, February 17, 2006 4:17:42 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Live Comment Preview
All content © 2009, John Luif