Bug 21521 - ProjectName has no value in xbuild
Summary: ProjectName has no value in xbuild
Status: NEW
Alias: None
Product: Tools
Classification: Mono
Component: xbuild ()
Version: 3.4.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2014-07-22 15:19 UTC by leankitryan
Modified: 2014-07-23 14:34 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 21521 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description leankitryan 2014-07-22 15:19:00 UTC
Add the following before build task to an Android or iOS project:

  <Target Name="BeforeBuild">
    <Exec Command="echo executing beforebuild for $(ProjectName) on mac os" Condition=" '$(OS)' == 'Unix' " />
    <Exec Command="echo executing beforebuild for $(ProjectName) on windows" Condition=" '$(OS)' == 'Windows_NT' " />

Output in Visual Studio or Xamarin Studio in Windows (where App.Android was the name of the project being built):

executing beforebuild for App1.Android on windows

Output in Xamarin Studio on a Mac:

executing beforebuild for on mac os

$(ProjectName) is being replaced with an empty string. I am seeing this same behavior across both Android and iOS projects.
Comment 1 Mikayla Hutchinson [MSFT] 2014-07-22 22:12:44 UTC
Is this before or after importing the common targets?
Comment 2 leankitryan 2014-07-23 08:42:06 UTC
After the imports. If I move the BeforeBuild target to before the imports it doesn't execute.  Also a correction, I am not seeing this with iOS projects on the Mac. I can't even get iOS projects to execute any before build / prebuild tasks in Mac OS but that's a separate issue.
Comment 3 Mikayla Hutchinson [MSFT] 2014-07-23 14:32:10 UTC
Looks like xbuild's version of Microsoft.Common.targets doesn't define the ProjectFile property.

As a workaround, you could use MSBuildProjectFile, which is defined by the engine.
Comment 4 Mikayla Hutchinson [MSFT] 2014-07-23 14:34:21 UTC
The MS version of the targets defines ProjectName as MSBuildProjectName if it's not explicitly set, anyway.