4

Can somebody please point me to a reference for the syntax of the expression language used in csproj / vbproj files within Visual Studio ? I've been seeing usages like the following :

 <FilesForPackagingFromProject Include="%(CustomFiles.Identity)">

... and I'm trying to understand the '.Identity' bit.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Alex Marshall
  • 10,162
  • 15
  • 72
  • 117
  • Good question. I'm working with Visual Studio 2012 Express and there are limitations in the interface that force me to edit the .csproj file of my project manually. I would also like to know where to find the documentation for the syntax. This question http://stackoverflow.com/questions/5129090/how-to-edit-csproj-file has some useful references. – DavidHyogo Jan 12 '13 at 03:33
  • This looks like a good starting point: http://www.asp.net/web-forms/tutorials/deployment/web-deployment-in-the-enterprise/understanding-the-project-file – DavidHyogo Jan 12 '13 at 03:46

2 Answers2

4

The Identity bit is one of many MSBuild Well-known Item Metadata. It is essentialy metadata of msbuild Items. You can use the metadata to Transform Item Types.

Marcos Brigante
  • 974
  • 9
  • 25
1

This question How do you include additional files using VS2010 web deployment packages? doesn't directly address your question but the most popular answer has loads of useful information and provides a clue as to what the % sign means.

<_CustomFiles Include="..\Extra Files\**\*" />
<FilesForPackagingFromProject  Include="%(_CustomFiles.Identity)">

I think the _CustomFiles tag creates a link to an external file, then %(_CustomFiles.Identity) refers to an element within that external file.

UPDATE:

NO! This is not right. The % expression gives a scalar value. The _CustomFiles is an Item and the .Identity part of the syntax refers to well-known metadata as explained by Marcos in the accepted answer.

Community
  • 1
  • 1
DavidHyogo
  • 2,838
  • 4
  • 31
  • 48
  • 1
    Thank you to whoever gave me an upvote - I'll accept it for effort, but this answer is wrong. This link helps to explain the difference between @, % and $ http://en.csharp-online.net/MSBuild:_By_Example%E2%80%94Understanding_the_Difference_between_@_and_%25. And this link may be better http://rationalgeek.com/blog/msbuild-propertygroup-itemgroup-item-metadata-and-crazy-syntax/ – DavidHyogo Jan 16 '13 at 01:45
  • Both links are now dead. The first link is a chapter from the book [Deploying .NET Applications: Learning MSBuild and ClickOnce (2006)](https://www.amazon.com/Deploying-NET-Applications-Learning-ClickOnce/dp/1590596528). I could not find an archived version of the page, but if you search for "MSBuild: By Example—Understanding the Difference between @ and %" you might find something. The second link is archived at [web.archive.org](https://web.archive.org/web/20200125051959/http://rationalgeek.com/blog/msbuild-propertygroup-itemgroup-item-metadata-and-crazy-syntax/) – Markus Jarderot Nov 24 '20 at 09:41