Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$(MSBuildProjectDirectory) and "program files (x86)" folder

Tags:

msbuild

I'm using the property MSBuildProjectDirectory with MSBuild.

The project is located in:

C:\Program Files (x86)\Jenkins\workspace\MyProject

During build MSBuildProjectDirectory is instead evaluated as:

C:\Program Files %28x86%29\Jenkins\workspace\MyProject

and I get a "The system cannot find the file specified" error.

Do I need to move to a different folder or can I get the right path?

like image 718
Be.St. Avatar asked Mar 22 '13 15:03

Be.St.


2 Answers

If you are using Visual Studio 2010 / MSBuild 4.0, this will happen with certain properties that contain parentheses. Microsoft admitted that this was a regression error from VS2008 to VS2010, when using MSBuild 4.0: http://connect.microsoft.com/VisualStudio/feedback/details/532677/msbuild-4-0-usingtask-cannot-have-a-path-with-parentheses

According to the above link, the following have an issue with parentheses:

  • UsingTask
  • MsBuildProjectDirectoryNoRoot
  • MsBuildProjectDirectory
  • MsBuildProjectFullPath

Resolution: For now, when using MSBuild 4.0, change the location to a path that does not contain parentheses.

like image 66
Michael Avatar answered Oct 12 '22 03:10

Michael


Use

$([MSBuild]::Unescape('$(MSBuildProjectDirectory)'))

instead of

$(MSBuildProjectDirectory)

like image 35
user6094291 Avatar answered Oct 12 '22 03:10

user6094291