473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Delayed evaluation of items in MSBUILD file

First, if there is a more appropriate newsgroup for MSBUILD questions,
please let me know.

I am trying to figure out how to create an item group that is evaluated
AFTER some tasks have already run. For example, the build file will
create a folder, and then copy various files into that folder. I then
want a task to do something with all of the files in that folder.
The way I currently have it setup will not work. I define a folder:
<PropertyGroup>
<BuildDir>Output</BuildDir>
</PropertyGroup>

And then an item that refers to the files in that folder:

<ItemGroup>
<CreatedFiles Include="$(BuildDir)\*" />
</ItemGroup>

And then use that item list when performing a task. (As you may know,
most tasks will not take wildcards as their parameters, they need an
expanded item list).
The problem is, the "CreatedFiles" item list will be evaluated when the
*build begins* (and the folder is empty). I want it to be evaluated when
it is *first used* (and files now exist in that folder).

Any ideas on how I can get the desired behavior (an item group that
references a list of files in a folder, after tasks have been run to
populate that folder)?

Here is a sample project file that will demonstrate the problem. The
first time you run it, it will create a file called FolderListing.txt,
with nothing in it. Run it again (without manually cleaning anything)
and the file will contain the names of the files in the Output folder.
The second run is the desired behavior - I need to figure out how to
make it work on the first run.
<Project DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildDir>Output</BuildDir>
</PropertyGroup>

<ItemGroup>
<CreatedFiles Include="$(BuildDir)\*" />
</ItemGroup>

<Target Name="Clean">
<RemoveDir Directories="$(BuildDir)" />
</Target>

<Target Name="Setup" DependsOnTargets="Clean">
<MakeDir Directories="$(BuildDir)" />
<Touch AlwaysCreate="true" Files="$(BuildDir)\a.txt" />
<Touch AlwaysCreate="true" Files="$(BuildDir)\b.txt" />
</Target>

<Target Name="Build" DependsOnTargets="Setup">
<WriteLinesToFile File="FolderListing.txt" Lines="@(CreatedFiles)" />
</Target>
</Project>
Dec 10 '05 #1
1 1688
If anyone else is trying to solve this problem, I received an answer on
the MSBUILD forums at:
http://forums.microsoft.com/MSDN/Sho...ID=27&SiteID=1
The solution is to use the CreateItem task.
Dec 11 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Leo Breebaart | last post by:
Hi all, I have a question about Python and delayed evaluation. Short-circuiting of Boolean expressions implies that in: >>> if a() and b(): any possible side-effects the call to b() might...
1
by: Uma Abhyankar | last post by:
Hello All, I was facing an issue with VCBuild on Beta1. Today after shifting to .NET Beta2, it looks like the issue is still not resolved :-( I have to invoke VCBuild through MSBuild on command...
1
by: Jianwei Sun | last post by:
I am trying to edit an MSBuild project file in the Visual Studio 2005. I tried to use the Intellisense of the editor, so I reference the xmlns at the first line like this: <Project...
2
by: minorguy | last post by:
I have a general question about MSBuild (which I know little about so far) and I hope this is the right newsgroup. I can read the reference documentation about MSBuild, but it's not really telling...
0
by: ccallen | last post by:
How to print msbuild <Messageto the VS 2005 output window, from an msbuild file that is loaded into VS? After reading Don Boxs' "MSBuild for MAKEFILE converts" , I copied the snippet, for point...
2
by: Jonathan Kacprowicz | last post by:
I am trying to create a build process using MSBuild that will build my multiple projects all with the same AssemblyVersion and AssemblyFileVersion. I have tried using the AssemblyInfo task from...
3
by: Danny | last post by:
Hi I trying to master msBuild but have a problem. I have a solution that I wish to build using msbuild but want to override BeforeBuild/AfterBuild targets for each of the projects. I trying to...
1
by: Divided Sky | last post by:
Is there an msbuild-specific discussion group? Also, is there an msbee discussion group that is active? Is there a good resource for info about using Microsoft.Build.BuildEngine.Engine class? ...
7
by: shapper | last post by:
Hello, I am working on an ASP.MET MVC Web Application with NET 3.5 in VS 2008. I need to run some extra tasks on this project build so I download MSBuild from http://msbuildtasks.tigris.org/....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.