Ayende @ Rahien

Hi!
My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:

ayende@ayende.com

+972 52-548-6969

, @ Q c

Posts: 6,125 | Comments: 45,488

filter by tags archive

How to setup dynamic groups in MSBuild without Visual Studio ruining them

time to read 2 min | 314 words

One of the really annoying things about VS & MSBuild is that while MSBuild is perfectly capable of doing things like this:

<EmbeddedResource Include="WebUI\**\*.*"/>

Visual Studio would go ahead, resolve the expression and then hard code the current values.

That sort of defeat the way I want to make use of it, which would make it frictionless to add more elements. If you do it in a slightly more complex way, VS can’t resolve this easily, so it does the right thing and compute this at build time, rather than replacing with the hard coded values.

Here is how you do it:

    <Target Name="BeforeBuild">
        <CreateItem Include="WebUI\**\*.*">
            <Output ItemName="EmbeddedResource" TaskParameter="Include" />
        </CreateItem>
    </Target>

Comments

styx31

What seems strange is that I've already used a wildcard to include all asmx in a web application. See my csproj :

<itemgroup
<content
<content
<content
<content

Perhaps the problem is only related to the <embeddedresource element ?

Ayende Rahien

Does it keep it as dynamic? When I tried it (on both compile & embedded resource), it just killed things

styx31

Sorry for the html in my comment. Manually html encoded version :

and read "to the EmbeddedResource xml element" ?

styx31

Yes, it works great when VS compile and on TFS Build also.

My ItemGroup is placed at the end of the csproj, after the two MS imports : Microsoft.CSharp.targets & Microsoft.WebApplication.targets, and before BeforeBuild & AfterBuild targets.

The bonus is that the files are displayed well in the solution explorer.

But I never add or remove solution items using visual studio, as this projet's goal is only to merge other web applications. Perhaps when VS add a file it makes all content references static.

Can I send you my .csproj file ?

Ayende Rahien

Oh, that explains it.

The project I am working on has dynamic & static content, which I edits.

When you make a modification, it seems to trigger the "to hard code" thingie

Comment preview

Comments have been closed on this topic.

FUTURE POSTS

  1. The design of RavenDB 4.0: Physically segregating collections - 16 hours from now
  2. RavenDB 3.5 Whirlwind tour: I need to be free to explore my data - about one day from now
  3. RavenDB 3.5 whirl wind tour: I'll have the 3+1 goodies to go, please - 5 days from now
  4. The design of RavenDB 4.0: Voron has a one track mind - 6 days from now
  5. RavenDB 3.5 whirl wind tour: Digging deep into the internals - 7 days from now

And 12 more posts are pending...

There are posts all the way to May 30, 2016

RECENT SERIES

  1. The design of RavenDB 4.0 (14):
    03 May 2016 - Making Lucene reliable
  2. RavenDB 3.5 whirl wind tour (14):
    04 May 2016 - I’ll find who is taking my I/O bandwidth and they SHALL pay
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats