views:

1019

answers:

1

Hi

I have the following task, which because of the combination of DestinationFiles and DestionationFolder does not work, but it grabs the concept of what I want to do:

<CreateItem Include="$(Destination)\**\*.Generated.*.*">
  <Output TaskParameter="Include" ItemName="GeneratedFiles" />
</CreateItem>

<Copy Condition=" '%(ConfigurationToBuild.FlavorToBuild)'=='Debug-All' Or '%(ConfigurationToBuild.FlavorToBuild)'=='Release-WebService' "
      SourceFiles="@(GeneratedFiles)"
      DestinationFiles="@(GeneratedFiles-&gt;'%(RecursiveDir)%(Filename)%(Extension)')"
      DestinationFolder="$(BinariesRoot)\%(ConfigurationToBuild.PlatformToBuild)\%(ConfigurationToBuild.FlavorToBuild)"
/>

So I have a set of files (data, not code) that are being generated, and these need to be copied to the final binaries location.

In this build, I build 3 configurations at once: a Debug-All version, a Release-Client version and a Release-WebService. The reasons is to keep the same build number and exact same code base, while having the Client and WebService projects 'published' and then picked up by the Setup projects.

If I try to use: DestinationFiles="@(GeneratedFiles->'$(BinariesRoot)\%(ConfigurationToBuild.PlatformToBuild)\%(ConfigurationToBuild.FlavorToBuild)\%(RecursiveDir)%(Filename)%(Extension)')"

MSBuild throws an error on the %(ConfigurationToBuild.FlavorToBuild) part.

A: 

I have found a workaround for this issue: i.e. duplicate the commands manually. So it is less generic and produces even more noise in the buildlog file, but at least it works!

<!-- Copy the updated files to the Binariesroot to have them picked up by the Setups -->
<CreateItem Include="$(Destination)\**\*.Generated.*.sql">
  <Output TaskParameter="Include" ItemName="GeneratedSqlFiles" />
</CreateItem>
<Message Text="GeneratedSqlFiles=@(GeneratedSqlFiles)->RecursiveDir=%(RecursiveDir) Filename=%(Filename)%(Extension)" />

<CreateProperty Condition=" '%(ConfigurationToBuild.FlavorToBuild)'=='Debug'" 
                Value="$(BinariesRoot)\%(ConfigurationToBuild.PlatformToBuild)\%(ConfigurationToBuild.FlavorToBuild)" >
  <Output TaskParameter="Value" PropertyName="RealBinariesRoot" />
</CreateProperty>
<Copy Condition=" '%(ConfigurationToBuild.FlavorToBuild)'=='Debug'"
      SourceFiles="@(GeneratedSqlFiles)"
      DestinationFiles="@(GeneratedSqlFiles->'$(RealBinariesRoot)\Deployment\%(RecursiveDir)%(Filename)%(Extension)')"
/>
<CreateProperty Condition=" '%(ConfigurationToBuild.FlavorToBuild)'=='WebService'"
            Value="$(BinariesRoot)\%(ConfigurationToBuild.PlatformToBuild)\%(ConfigurationToBuild.FlavorToBuild)" >
  <Output TaskParameter="Value" PropertyName="RealBinariesRoot" />
</CreateProperty>
<Copy Condition=" '%(ConfigurationToBuild.FlavorToBuild)'=='WebService'"
      SourceFiles="@(GeneratedSqlFiles)"
      DestinationFiles="@(GeneratedSqlFiles->'$(RealBinariesRoot)\Deployment\%(RecursiveDir)%(Filename)%(Extension)')"
/>

Also found in the meantime that if you have a '.' in the Include path of a CreateItem task, the RecursiveDir property is no longer filled in. So having

'drive:\somefolder\subfolder\Sources\Generated***.Generated.*.sql' will provide the %(RecursiveDir) metadata. Using

'drive:\somefolder\subfolder\.\Sources\Generated***.Generated.*.sql', which resolves to the same path as above will NOT provide the %(RecursiveDir) metadata. (note the subtle '.' between subfolder and Sources)

Ofcourse (Murphy's law) we use this to specify which branch needs te be build, with . pointing to the Main branch ;-)

Rudi