msbuild -p:outputdir=c:\mydir being ignored

I'm running msbuild from the command line with the following:

msbuild mysolution.sln -p:outputdir=c:\mydir

When I run this, the outputdir is being ignored and the default specified in the csproj file is being used.

The MSDN doc for this tool says that I should be able to override the build directory using this parameter. What am I doing wrong?


You should use OutputPath and more important you should use the right syntax :

msbuild mysolution.sln /p:OutputPath=c:\mydir

Note that OutputPath is preferred over OutDir. The documentation used to be wrong about this, but I see that they've finally fixed it.

Beyond that, it's difficult to say exactly what the problem is, since you didn't show the exact path that you're passing as a parameter. There are two possible problems that I can imagine:

  1. The OutputPath option specifies the path to the output directory relative to the project directory. That means you can't set it to a global path like C:\mydir. I assume it is unable to find the path you specified, and so it defaults to the one specified in your project file.

  2. If the path that you're actually specifying as a parameter contains spaces, the command is likely to fail. I believe you need to wrap the path in quotes and append an extra backslash to the end of the path string.


I believe you should be using OutputPath.


I was able to configure OutDir for MSBuild command line. Please see my answer at the link below with the command. See my answer https://stackoverflow.com/a/26477048/1006422