William - thankyou so much, this worked perfectly! 
 
You've now become my MSBuild expert.
 
I owe you a beer.
 
 
Grant

________________________________

From: [EMAIL PROTECTED] on behalf of William Bartholomew
Sent: Mon 15/01/2007 3:24 PM
To: [email protected]
Subject: RE: [OzTFS] MSBuild AssemblyInfo community task



Grant,

 

You might want to look at the meta-data capabilities of MSBuild. Your 
GetAssemblyVersion task could then return an array of TaskItems with a 
meta-data attribute called Version. You could then pass these task items into 
the next task which could then use the Version meta-data.

 

This is roughly how this would work:

 

<GetAssemblyVersion AssemblyInfoFilename="%(AssemblyInfos.FullPath)">
      <Output TaskParameter="AssemblyVersion" PropertyName="AssemblyVersion"/>
</GetAssemblyVersion>

 

  <AssemblyInfo CodeLanguage="CS"
   OutputFile="%(AssemblyInfos.FullPath)"
   AssemblyTitle="$(BuildType)"

   AssemblyVersion="%(AssemblyInfos.Version)"

 

This would only require the GetAssemblyVersion task to be modified. You would 
need to:

 

1.       Change the AssemblyInfoFilename property from a string to a TaskItem 
array.

2.       Change the argument passed from "%(AssemblyInfos.FullPath)" to 
"@(AssemblyInfos.FullPath)". (This is so that you are operating on a set not 
individual items).

3.       Modify the GetAssemblyVersion task to loop through the 
AssemblyInfoFilename array in the Execute method.

4.       Once you have determined the version call SetMetadata( "Version", 
"2.2.0.50" ) on the current item in the loop.

 

MSBuild is much closer to a set-based language (such as SQL) than a procedural 
language. You get the most bang for your buck if your tasks operate on sets and 
leverage meta-data.

 

Hope this helps,

William

 

________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Grant Holliday
Sent: Monday, 15 January 2007 2:08 PM
To: [email protected]
Subject: RE: [OzTFS] MSBuild AssemblyInfo community task

 

No, not quite that simple.

 

GetAssemblyVersion is a custom task that reads the version and ensures that it 
matches the correct standards as well as adding the current build number.

 

So if AssemblyInfo.cs says "2.2.0.*", it replaces the * with the current 
$(BuildNumber) e.g. 2.2.0.50 (if the build has been run 50 times)

 

 

________________________________

From: [EMAIL PROTECTED] on behalf of William Bartholomew
Sent: Mon 15/01/2007 3:00 PM
To: [email protected]
Subject: RE: [OzTFS] MSBuild AssemblyInfo community task

Grant,

 

Am I missing something here? It looks like you want to read the assembly 
version from the file and then write it back into the file without any changes?

 

William

 

________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Grant Holliday
Sent: Monday, 15 January 2007 1:49 PM
To: [email protected]
Subject: RE: [OzTFS] MSBuild AssemblyInfo community task

 

OK - next problem. How do you do a 'foreach' in msbuild?

 

I want to call this task:

    <GetAssemblyVersion AssemblyInfoFilename="%(AssemblyInfos.FullPath)">
      <Output TaskParameter="AssemblyVersion" PropertyName="AssemblyVersion"/>
    </GetAssemblyVersion>

 

For each assembly, then use the $(AssemblyVersion) property that it outputs to 
feed into the <AssemblyInfo> task for each file.

 

So in pseudocode, the flow would look like this:

  Find all AssemblyInfo.cs files

  foreach $file in AssemblyInfos

  {

    $version = GetAssemblyVersion($file) 

    Call AssemblyInfo($file, $version)

  }

 

Any ideas?

 

________________________________

From: [EMAIL PROTECTED] on behalf of Grant Holliday
Sent: Mon 15/01/2007 1:23 PM
To: [email protected]
Subject: RE: [OzTFS] MSBuild AssemblyInfo community task

Thanks Chris - this did the trick. I suspected it was something like this.

 

Thanks also William - It's actually just a string.

 

________________________________

From: [EMAIL PROTECTED] on behalf of Chris Burrows
Sent: Mon 15/01/2007 1:13 PM
To: [email protected]; [email protected]
Subject: RE: [OzTFS] MSBuild AssemblyInfo community task

Grant,

 

If you replace the 

 

  <AssemblyInfo CodeLanguage="CS"
   OutputFile="@(AssemblyInfos)"
   AssemblyTitle="$(BuildType)"

with 

 

  <AssemblyInfo CodeLanguage="CS"
   OutputFile=%(AssemblyInfos.FullPath)"
   AssemblyTitle="$(BuildType)"

It should cause it call the task to be called multiple times.

 

Cheers


Chris

 

Chris Burrows

Readify | Senior Consultant

 

Suite 206 Nolan Tower | 29 Rakaia Way | Docklands | VIC 3008 | Australia 

M: +61 404 254 654 | E: [EMAIL PROTECTED] | C: [EMAIL PROTECTED] | W: 
www.readify.net <http://www.readify.net/> 

 

________________________________

From: [EMAIL PROTECTED] on behalf of William Bartholomew
Sent: Mon 15/01/2007 12:59 PM
To: [email protected]
Subject: RE: [OzTFS] MSBuild AssemblyInfo community task

Grant,

 

Have a look at the definition of OutputFile in their documentation (or 
Reflector), if it's a TaskItem then MSBuild will call the task once for each 
AssemblyInfo, if it's a TaskItem array then MSBuild will only call it once.

 

William

 

________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Grant Holliday
Sent: Monday, 15 January 2007 11:51 AM
To: [email protected]
Subject: [OzTFS] MSBuild AssemblyInfo community task

 

Has anybody had any experience with the AssemblyInfo task from the 
msbuildtasks.com guys?

 

I'm trying to run the task for all AssemblyInfo.cs's in the BeforeCompile 
override.

 

<Target Name="BeforeCompile">
 <Target Name="AssemblyInfo">
    <CreateItem Include="$(SolutionRoot)\**\AssemblyInfo.cs">
      <Output ItemName="AssemblyInfos" TaskParameter="Include"/>
    </CreateItem>

    <Attrib ReadOnly="false" Files="@(AssemblyInfos)" />

    <AssemblyInfo CodeLanguage="CS"
   OutputFile="@(AssemblyInfos)"
   AssemblyTitle="$(BuildType)"
    />  
</Target>

 

But I'm getting an error:

error MSB4018: The "AssemblyInfo" task failed unexpectedly.
error MSB4018: System.IO.PathTooLongException: The specified path, file name, 
or both are too long. The fully qualified file name must be less than 260 
characters, and the directory name must be less than 248 characters.

 

After checking the contents of @(AssemblyInfos), none of the individual paths 
are more than about 120chars. But the total string would be much longer.

 

I suspect the OutputFile attribute doesn't like outputting multiple files.

 

How would I call the AssemblyInfo task for each AssemblyInfo.cs in 
@(AssemblyInfos) ?

 

 

Grant

OzTFS.com - to unsubscribe from this list, send a message back to the list with 
'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net OzTFS.com - to 
unsubscribe from this list, send a message back to the list with 'unsubscribe' 
as the subject.
Powered by mailenable.com - List managed by www.readify.net 

OzTFS.com - to unsubscribe from this list, send a message back to the list with 
'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net 

OzTFS.com - to unsubscribe from this list, send a message back to the list with 
'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net 

OzTFS.com - to unsubscribe from this list, send a message back to the list with 
'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net 



OzTFS.com - to unsubscribe from this list, send a message back to the list with 
'unsubscribe' as the subject.

Powered by mailenable.com - List managed by www.readify.net

<<winmail.dat>>

Reply via email to