Auswertung von ItemGroups in msbuild

Standard

Neulich hatte ich das Problem, dass ItemGroups in msbuild offenbar
einmal zu Beginn ausgewertet werden und danach die Liste der Items bis
zum Ende des Builds nicht mehr aktualisiert wird. Wenn während des
Builds Verzeichnisse oder Dateien gelöscht bzw. erzeugt werden, stimmt
der Inhalt der ItemGroup nicht mehr mit dem tatsächlichen
Dateisysteminhalt überein.

Normalerweise ist das kein Problem, weil erstens der Source-Code zu
Beginn feststeht und diese Dateien während des Build-Prozesses nicht
gelöscht werden und zweitens Build-Artefakte, die in den nächsten
Buildsteps weiterverarbeitet werden, als Output-Parameter der Tasks zur
Verfügung stehens.

Ein Problem hat man allerdings, wenn man Tasks verwendet, die die
erzeugten Dateien nicht als Output-Parameter zur Verfügung stellen
(können) und diese Dateien weiterverarbeitet werden sollen.

Im folgenden Code-Snippet werden rekursiv alle Namen von
C#-Quellcodedateien ausgegeben, ein Verzeichnis gelöscht und danach
wieder alle C#-Dateinamen ausgegeben:

<project DefaultTargets="TestItems" xmlns="...">
  <itemGroup>
    <myItems Include="**.cs" />
  </itemGroup>
  <target Name="TestItems">
    <message Text="@(MyItems)" />
    <removeDir Directories="TestDir" />
    <message Text="@(MyItems)" />
  </target>
</project>

Auch nach dem Löschen des Verzeichnisses sind alle Dateien dieses
Verzeichnisses in der ItemGroup “MyItems” enthalten.

Um die ItemGroups aktuell zu halten, kann man den CreateItem-Task
verwenden:

<project DefaultTargets="TestItems" xmlns="...">
  <itemGroup>
    <myItems Include="**.cs" />
  </itemGroup>
  <target Name="TestItems">
    <message Text="@(MyItems)" />
    <removeDir Directories="TestDir" />
    <createItem Include="**.cs">
      <output TaskParameter="Include" ItemName="CurrentItems" />
    </createItem>
    <message Text="@(MyItems)" />
  </target>
</project>

In einigen Situationen ergeben sich daraus ziemlich unleserliche
Build-Skripts. Doch sollte man sich dann überlegen, ob msbuild das
richtige Tool ist.

294 thoughts on “Auswertung von ItemGroups in msbuild

  1. wh0cd133542 [url=http://sildenafilonline.doctor/]buy sildenafil online[/url] [url=http://genericsynthroid.doctor/]home page[/url] [url=http://buytorsemide.doctor/]buy torsemide[/url]

  2. wh0cd287573 [url=http://cheapantabuse.doctor/]cheap antabuse[/url] [url=http://orderkamagra.doctor/]kamagra jelly usa[/url] [url=http://buyzyban.doctor/]zyban over the counter[/url] [url=http://buyvpxl.doctor/]vpxl[/url]

  3. I would like to express my respect for your kindness for folks who absolutely need help with that area. Your personal commitment to passing the solution around has been exceedingly important and has surely made guys and women much like me to reach their endeavors. Your own warm and friendly guide signifies so much a person like me and substantially more to my office colleagues. Thank you; from everyone of us.

  4. Greate post. Keep writing such kind of information on your site.

    Im really impressed by it.
    Hi there, You have done an excellent job. I’ll
    definitely digg it and individually suggest to my friends.
    I am sure they’ll be benefited from this website.

  5. Wow, marvelous blog layout! How long have you been blogging for?
    you made blogging look easy. The overall look of your
    site is wonderful, as well as the content!

  6. I was suggested this website by my cousin. I’m not sure whether this post is written by him as nobody else know such detailed about my problem. You’re amazing! Thanks!

  7. I’d need to test with you here. Which is not one thing I normally do! I get pleasure from studying a put up that may make people think. Additionally, thanks for permitting me to remark!

  8. There are some attention-grabbing cut-off dates in this article however I don’t know if I see all of them heart to heart. There may be some validity however I will take maintain opinion until I look into it further. Good article , thanks and we would like extra! Added to FeedBurner as well

  9. I was suggested this website by my cousin. I’m not sure whether this post is written by him as nobody else know such detailed about my problem. You’re amazing! Thanks!

  10. There are some interesting points in time in this article however I don’t know if I see all of them heart to heart. There’s some validity but I will take maintain opinion till I look into it further. Good article , thanks and we would like more! Added to FeedBurner as nicely

  11. I was suggested this website by my cousin. I’m not sure whether this post is written by him as nobody else know such detailed about my problem. You’re amazing! Thanks!

  12. I’m really loving the theme/design of your weblog.
    Do you ever run into any browser compatibility issues?

    A couple of my blog readers have complained about my site not operating correctly in Explorer but looks great
    in Opera. Do you have any ideas to help fix this problem?

  13. Oh my goodness! a tremendous article dude. Thank you However I’m experiencing problem with ur rss . Don’t know why Unable to subscribe to it. Is there anybody getting similar rss drawback? Anybody who is aware of kindly respond. Thnkx

  14. Hello there, just became aware of your blog through Google, and found
    that it’s really informative. I’m gonna watch out for brussels.
    I’ll appreciate if you continue this in future. A lot of people will
    be benefited from your writing. Cheers!

  15. Hello fantastic blog! Does running a blog such as this require a large amount of work?
    I’ve virtually no understanding of programming however I had been hoping to start my own blog soon. Anyway, should you have
    any suggestions or techniques for new blog owners please share.
    I know this is off topic nevertheless I simply had to ask.
    Thank you!

  16. Thanks , I have recently been looking for info approximately
    this topic for ages and yours is the greatest I
    have discovered till now. However, what in regards to the bottom line?
    Are you sure in regards to the supply?

  17. Mario Balotelli insists he will not make any more mistakes off the pitch because he rarely leaves his home – and says that anyone who thinks he has sex just before a match is having a laugh. Mario Balotelli says there will be no more fireworks off the pitch as Liverpool striker vows to focus on football (and he doesn’t have sex just before a match!)

  18. When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time
    a comment is added I get several emails with the same comment.
    Is there any way you can remove people from that service?
    Cheers!

  19. I’m impressed, I must say. Seldom do I encounter a blog that’s
    both educative and engaging, and let me tell you, you have hit the
    nail on the head. The issue is something which too few
    men and women are speaking intelligently about.
    Now i’m very happy that I came across this during
    my search for something relating to this.

  20. Tried to find any method of additional income and always failed until I finally found something legit: http://bit.ly/2ODt2Tt – You get 30 on all products, all you have to do is copy your affiliate link and comment on blogs, forums etc. Just register and confirm your accouunt, go to affiliate links section, copy your favorite product link and spread it all over the internet. Piece of cake!

  21. I know this if off topic but I’m looking into starting my own weblog and was curious what
    all is needed to get set up? I’m assuming having a blog like yours would cost a pretty
    penny? I’m not very web smart so I’m not 100% sure.
    Any recommendations or advice would be greatly appreciated.
    Cheers

  22. Do you mind if I quote a couple of your articles as long as I
    provide credit and sources back to your site? My blog site is in the very same niche as yours and my visitors would definitely benefit from a lot of
    the information you provide here. Please let me know if this okay with you.
    Many thanks!

  23. I’d need to test with you here. Which is not one thing I normally do! I get pleasure from studying a put up that may make people think. Additionally, thanks for permitting me to remark!

  24. A formidable share, I simply given this onto a colleague who was doing just a little analysis on this. And he in reality bought me breakfast as a result of I discovered it for him.. smile. So let me reword that: Thnx for the treat! However yeah Thnkx for spending the time to debate this, I feel strongly about it and love studying extra on this topic. If possible, as you develop into expertise, would you mind updating your blog with more particulars? It’s extremely helpful for me. Large thumb up for this blog publish!

  25. There are some interesting points in time in this article however I don’t know if I see all of them heart to heart. There’s some validity but I will take maintain opinion till I look into it further. Good article , thanks and we would like more! Added to FeedBurner as nicely

Leave a Reply

Your email address will not be published.