190

How can I get a list of built-in MSBuild variables?

I need to know how to determine the current project's csproj name, and thought it might be useful to know what else I can find out in MSBuild.

Filip Skakun
  • 31,624
  • 6
  • 74
  • 100
Khanzor
  • 4,830
  • 3
  • 25
  • 41

6 Answers6

253

Comprehensive lists from Microsoft Docs (New Docs):

Comprehensive lists from MSDN (Legacy Docs):

Other useful lists:

First link shows the MSBuild property for project name:

MSBuildProjectName The file name of the project file without the file name extension

si618
  • 16,580
  • 12
  • 67
  • 84
  • 2
    I would also include https://learn.microsoft.com/en-us/dotnet/core/tools/csproj#assemblyinfo-properties. Those properties are quite useful when migrating to the new csproj format. – cao May 15 '19 at 08:22
11

http://msdn.microsoft.com/en-us/library/c02as0cs(loband).aspx

i_am_jorf
  • 53,608
  • 15
  • 131
  • 222
  • 2
    This is a link to the list of macros mentioned in the later question. I believe these are properties set by VS, so note that if building from command line - these values won't be set. – Filip Skakun Jan 27 '16 at 03:56
5

This seems like a pretty thorough list: Common macros for MSBuild commands and properties

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
JonathonW
  • 857
  • 7
  • 17
4

These properties can also be defined by 3rd-party tools so to get the complete list I just use (in a C++ project for example): Properties -> Configuration Properties -> General -> then on the Output or Intermediate Directory drop down choose Edit... and you should see a list of all defined properties.

2

There are also Agent and Build predefined variables for pipelines: https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml. These are the variables I was looking for when I came across this article, so I thought I'd pass the link along when I finally found them.

ckkkitty
  • 165
  • 2
  • 6
1

I would also include a list of List of Common Properties and Parameters for MSBuild.

Also, the properties depend on which version of MSBuild you are using. There are 3 versions.

SoftwareCarpenter
  • 3,835
  • 3
  • 25
  • 37