Repository navigation
[tests] fix for FSharp targets on Windows - #1064
Conversation
Context: https://devdiv.visualstudio.com/DevDiv/Default/_build/index?buildId=1188880&_a=summary&tab=ms.vss-test-web.test-result-details Our FSharp tests are failing on Windows due to the way we are having to import `Microsoft.FSharp.targets`: ``` <Import Condition="'$(Language)' != 'F#' And Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')" Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets" /> ``` Since `xabuild.exe` is modifying `$(MSBuildExtensionsPath)` to a path in XA's build tree, the `Condition` always evaluates to `False`--even though the search path fallbacks would have located it. Since we are having to use `Condition` and check for multiple paths for F#, MSBuild's search path fallback logic will not be able to work in this file. Two changes to improve this, which should fix the tests on Windows: - Added F# 4.1 directory searching, as this was missing - Added a lookup of the `FSHARPINSTALLDIR` environment variable. This was installed system-wide on my machine from Visual Studio 2017 15.4. It is also already set on our VSTS build agents.
|
@jonathanpeppers, |
| <Import | ||
| Condition="'$(Language)' != 'F#' And Exists('$(FSharpInstallDir)Microsoft.FSharp.Targets')" | ||
| Project="$(FSharpInstallDir)Microsoft.FSharp.Targets" /> | ||
| <Import |
There was a problem hiding this comment.
Is the order important for these imports? Which should be preferred? I assume if both exist the last one will be used (as it will overwrite all the bits from the other.. maybe)
There was a problem hiding this comment.
@dellis1972 I think $(Language) gets set to F# as soon as one is imported, so it should pick the first one that loads.
There was a problem hiding this comment.
Is the order important for these imports?
Yes.
As @jonathanpeppers notes, the '$(Language)' != 'F#' check ensures that the first "existing" <Import/> "wins." As soon as a file is found an imported, the expectation is that file will set <Language>F#</Language>, which will prevent subsequent imports from actually importing.
There was a problem hiding this comment.
That said, I have no idea what the order should be here. :-(
There was a problem hiding this comment.
I tested what it's doing here a little bit.
If you are inside VS, it loads this one because $(VisualStudioVersion) is set: $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets
If you are MSBuild command line, it picks the newest F# you have installed, such as: $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\4.1\Framework\v4.0\Microsoft.FSharp.Targets
My FSHARPINSTALLDIR is set to C:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0\.
So perhaps the order should be:
- Try the VS one
- Try the environment variable
- Try 4.1
- Try 4.0
- Try 3.1
I happened to have code in this PR like in this order already. Thinking it through a little more, what do you guys think?
Changes: https://github.com/xamarin/monodroid/compare/2c9ce23d...dab75e88 Fixes: https://work.azdo.io/1041849 Fixes: https://developercommunity.visualstudio.com/content/problem/858509/adb0030-monoandroidtoolsrequiresuninstallexception-2.html * xamarin/monodroid@dab75e880: Bump to xamarin/android-sdk-installer/d16-5@5adcbfa (#1066) * xamarin/monodroid@3293f67a9: Bump to xamarin/android-sdk-installer/d16-5@dd6e2c0 (#1063) * xamarin/monodroid@8ecaa9d30: [tools/msbuild] prevent InstallPackageAssemblies from reporting two errors (#1058) (#1064) * xamarin/monodroid@284b81933: Bump to xamarin/androidtools/d16-5@62844ab (#1062)
Context: https://devdiv.visualstudio.com/DevDiv/Default/_build/index?buildId=1188880&_a=summary&tab=ms.vss-test-web.test-result-details
Our FSharp tests are failing on Windows due to the way we are having to
import
Microsoft.FSharp.targets:Since
xabuild.exeis modifying$(MSBuildExtensionsPath)to a path inXA's build tree, the
Conditionalways evaluates toFalse--even thoughthe search path fallbacks would have located it. Since we are having to
use
Conditionand check for multiple paths for F#, MSBuild's search pathfallback logic will not be able to work in this file.
Two changes to improve this, which should fix the tests on Windows:
FSHARPINSTALLDIRenvironment variable. Thiswas installed system-wide on my machine from Visual Studio 2017 15.4. It
is also already set on our VSTS build agents.