Bug 17802 - xbuild evaluates Exist wrongly when the item group does not exist
Summary: xbuild evaluates Exist wrongly when the item group does not exist
Alias: None
Product: Tools
Classification: Mono
Component: xbuild ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2014-02-16 04:34 UTC by Lex Li
Modified: 2014-02-18 18:23 UTC (History)
1 user (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 on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Lex Li 2014-02-16 04:34:31 UTC
I did not know if this is related with https://bugzilla.xamarin.com/show_bug.cgi?id=11766, but attached below is a sample MSBuild script that reproduces the issue I met,

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="RestorePackages">        
        <Warning Text="Should not see this" Condition="Exists('$(PackagesConfig)')" />

When running on Windows/.NET MSBuild gives,

E:\Projects\sharpmibsuite\sharpsnmplib\.nuget>msbuild test.proj /t:RestorePacka
Microsoft (R) Build Engine version 12.0.30110.0
[Microsoft .NET Framework, version 4.0.30319.34011]
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 2/16/2014 5:09:01 PM.

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.02


When running on Ubuntu/Mono xbuild gives,

lextm@lextm-virtual-machine:~/src$ xbuild test.proj /t:RestorePackages
XBuild Engine Version
Mono, Version
Copyright (C) Marek Sieradzki 2005-2008, Novell 2008-2011.

Build started 2/16/2014 5:10:20 PM.
Project "/home/lextm/src/test.proj" (RestorePackages target(s)):
	Target RestorePackages:
/home/lextm/src/test.proj:  warning : Should not see this
Done building project "/home/lextm/src/test.proj".

Build succeeded.


/home/lextm/src/test.proj (RestorePackages) ->
(RestorePackages target) ->

	/home/lextm/src/test.proj:  warning : Should not see this

	 1 Warning(s)
	 0 Error(s)

Time Elapsed 00:00:00.1049850

This issue prevents NuGet package restore from working on Linux as NuGet targets uses such testing. Please try to fix it ASAP.

I test against latest Mono https://github.com/mono/mono/commit/50685c9733f66d54e18fc1fe6246c914306b511f but the test still breaks.
Comment 1 Mikayla Hutchinson [MSFT] 2014-02-16 04:50:11 UTC
Apparently MSBuild considers "Exists ('')" to be true.
Comment 2 Mikayla Hutchinson [MSFT] 2014-02-18 18:23:48 UTC
Err, I meant xbuild considers "Exists ('')" to be true.

The issue was that if the value passes to Exists was not rooted, we combined it with the project directory to create an absolute path. For an empty string, that resulted in the project directory, which exists.

Fixed in master.