Bug 53186 - Xamarin.Mac.FSharp.targets: Project file could not be imported
Summary: Xamarin.Mac.FSharp.targets: Project file could not be imported
Alias: None
Product: Tools
Classification: Mono
Component: xbuild ()
Version: unspecified
Hardware: PC Mac OS
: --- major
Target Milestone: ---
Assignee: Ankit Jain
Depends on:
Reported: 2017-03-09 12:07 UTC by Marek Safar
Modified: 2017-03-13 22:28 UTC (History)
1 user (show)

Tags: 2017-02
Is this bug a regression?: Yes
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 Marek Safar 2017-03-09 12:07:43 UTC
/var/folders/zw/_2mb6txx19b1c3g9ls4mwngr0000gn/T/msbuild-tests/FSharpXM45Example.fsproj: error : /var/folders/zw/_2mb6txx19b1c3g9ls4mwngr0000gn/T/msbuild-tests/FSharpXM45Example.fsproj: /Users/marek/git/my/xamarin-macios/_mac-build/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Mac/Xamarin.Mac.FSharp.targets: Project file could not be imported, it was being imported by /var/folders/zw/_2mb6txx19b1c3g9ls4mwngr0000gn/T/msbuild-tests/FSharpXM45Example.fsproj: /Users/marek/git/my/xamarin-macios/_mac-build/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Mac/Xamarin.Mac.FSharp.targets could not import "$(FSharpTargets)"

To repro
1. clone https://github.com/xamarin/xamarin-macios/tree/mono-2017-02 branch
2. build
3. xamarin-macios/tests$ make run-mac-msbuild
Comment 2 Ankit Jain 2017-03-10 21:59:32 UTC
`Xamarin.Mac.FSharp.targets` has:

<FSharpTargets Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets')">$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargets>

and then

<Import Project="$(FSharpTargets)" />

`MSBuildExtensionsPath` supports search paths only if the string `$(MSBuildExtensionsPath)` (or *32/*64) appear in the `Project` attribute of the `Import` element. Otherwise the value of the property or the default value is used.

Instead, you will have to use:

        <Import Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets')"
                Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets" />

        <Import Condition="!$(MSBuildAllProjects.Contains('Microsoft.FSharp.Targets')) and Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')"
                Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets" />

        <Import Condition="!$(MSBuildAllProjects.Contains('Microsoft.FSharp.Targets')) and Exists('$(MSBuildFrameworkToolsPath32)\Microsoft.FSharp.Targets')"
                Project="$(MSBuildFrameworkToolsPath32)\Microsoft.FSharp.Targets" />

        <Import Condition="!$(MSBuildAllProjects.Contains('Microsoft.FSharp.Targets'))"
                Project="$(MSBuildBinPath)\Microsoft.FSharp.Targets" />

The test passes with the above.
Comment 3 Ankit Jain 2017-03-13 22:28:28 UTC
Committed to `mono-2017-02` branch. Tests pass:

test-mac-msbuild	Tests run: 14, Passed: 14, Errors: 0, Failures: 0, Inconclusive: 0