Bug 22981 - ToolTask.ToolPath vs ToolTask.GenerateFullPathToTool behavior differs from MSBuild
Summary: ToolTask.ToolPath vs ToolTask.GenerateFullPathToTool behavior differs from MS...
Status: RESOLVED FIXED
Alias: None
Product: Tools
Classification: Mono
Component: xbuild ()
Version: unspecified
Hardware: Other Linux
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2014-09-14 17:54 UTC by Micah Zoltu
Modified: 2014-09-15 07:38 UTC (History)
2 users (show)

Tags:
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:
Status:
RESOLVED FIXED

Description Micah Zoltu 2014-09-14 17:54:15 UTC
Steps to reproduce:
1. Create a custom ToolTask derived from Microsoft.Build.Utilities.ToolTask.
2. Create a UsingTask entry for it in your project.  <UsingTask TaskName="MyTask" AssemblyFile="$(MSBuildThisFileDirectory).\MyTask.dll" />
3. Call the task in a target, providing the ToolPath.  <Target><MyTask ToolPath="some/other/path/to/tool.exe"/></Target>
4. Execute the build script.

In MSBuild, the above steps will locate and use the tool found at some/other/path/to/tool.exe.  In XBuild, the path supplied by GenerateFullPathToTool is used.

I believe the source of the problem is here:
https://github.com/mono/mono/blob/60d9c66011594d2572c3cda163da8beb8d6b999d/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs#L98

That should instead be something like:

ToolPath ?? GenerateFullPathToTool()
Comment 1 Micah Zoltu 2014-09-14 18:01:42 UTC
This bug can be reproduced by attempting to utilize the NuGet.for.MSBuild NuGet package.  This package adds a build tool and some build tasks/targets.  In particular, the NuGet.MSBuild.Tools.Pack task looks like:

<NuGet.MSBuild.Tools.Pack
  Project="$(NuGetProjectPath)"
  OutputDirectory="$(OutDir)"
  Symbols="$(BuildNuGetSymbolsPackage)"
  BasePath="$(OutDir)"
  Version="$(PackageVersion)"
  CustomSwitches="$(CustomNuGetPackSwitches)"
  ToolPath="$(NuGetToolPath)"
  Configuration="$(Configuration)"
  Platform="$(Platform)"/>

And the underlying ToolTask that overrides GenerateFullPathToTool can be found here:
http://nuget4msbuild.codeplex.com/SourceControl/latest#Trunk/src/NuGet.MSBuild.Tools/NuGetTask.cs

This works when building with MSBuild, but fails when building with XBuild 3.8.0.0.
Comment 2 Micah Zoltu 2014-09-14 18:04:38 UTC
Pull request that *should* fix the problem (untested, I don't have a mono environment setup):
https://github.com/mono/mono/pull/1285
Comment 3 Marek Safar 2014-09-15 07:38:51 UTC
Fixed in master