-
Notifications
You must be signed in to change notification settings - Fork 123
Parsing an iOS classic project causes an exception #366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I dont know why but Unfortunately because of this exception we get no tooltips, completion or semantic highlighting in classic iOS at all, which is really bad and unshippable really. |
@rneatherway @dsyme Any ideas here? |
Any clues in the log output? I've never built an iOS project, so unlikely to be able to help. |
Theres no log output, it throws before that. In an iOS classic theres an target like this:
Which looks like this:
|
From the error it looks like |
Where exactly does that file live? Which version of xbuild is it under? On Wed, Jul 8, 2015 at 2:48 PM, Dave Thomas notifications@github.com
|
Is the FSharp targets file actually at the right path? There was a bug in fsharp/fsharp (fixed yesterday) that was putting it at the wrong place |
It lives here: F# seems to be ok, and everything build ok, so the target is found normally during a build. |
It could be that the expansion is triggering the same issue that android suffers from and the exception is being masked. It could be masked, perhaps, by the fact this target imports another |
I just checked and unified iOS project fail in the same way, so all in all no mobile platforms work because the checker options generator is broken for all of them. |
Slightly more detailed exception, it crashed in the ctor so its a bit nasty: Microsoft.Build.BuildEngine.InvalidProjectFileException: /Users/dave/Projects/sv_classic_ios/sv_classic_ios/sv_classic_ios.fsproj: /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.MonoTouch.FSharp.targets: Project file could not be imported, it was being imported by /Users/dave/Projects/sv_classic_ios/sv_classic_ios/sv_classic_ios.fsproj: /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.MonoTouch.FSharp.targets could not import "$(FSharpTargets)" ---> Microsoft.Build.BuildEngine.InvalidProjectFileException: /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.MonoTouch.FSharp.targets: Project file could not be imported, it was being imported by /Users/dave/Projects/sv_classic_ios/sv_classic_ios/sv_classic_ios.fsproj: /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.MonoTouch.FSharp.targets could not import "$(FSharpTargets)" ---> Microsoft.Build.BuildEngine.InvalidProjectFileException: /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.MonoTouch.FSharp.targets could not import "$(FSharpTargets)" |
Just a note, its definitely the import that trips it up: |
So its trying to import
|
Dors this file exist on disk? `‘$(MSBuildExtensionsPath32)..\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets'`` ? |
Ok so FsharpTargets must be evaluated incorrect, when I finally managed to get the info out of the debugger:
Which doesn't exist. This stuff is pretty awful to debug. |
I think there needs to be a double bind of FSharpTargets in the import file to cater for the two location checks. |
Ah, good debugging. It seems like Using a backup location of The other is to reflection-bind to MSBuild like @dsyme suggested elsewhere, so that we can use 4.0 on Mono and 12.0 on Windows. That might also solve the android (cast) problem, but would require some testing. |
Even if I add: <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>
<FSharpTargets Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargets>
<FSharpTargets Condition="'$(FSharpTargets)' == ''">$(MSBuildBinPath)\Microsoft.FSharp.targets</FSharpTargets> I still get the last match, the first two do exist though??? |
See my last comment, I think that |
I still have the debug session open, the value of MSBuildExtensionsPath32 is: |
Huh, seems like a bug in the Mono MSBuild implementation then. |
Ill try the backup you suggested, the one thats there currently never exists as far as I know anyway. |
Trouble is that my backup uses |
The last condition is based on '' though. The issue might be to do with some bug in the condition logic in the import processing maybe? |
Right, I suppose |
This is weird. It ends up setting Even though I set it to: I have no idea why its doing that? |
It seems like something is lying to us! So |
Yeah thats where the ios, mac and android targets are, Im not sure whats going on to be honest! |
In terms of evaluated properties - But if I slip an extra property in to see what was happening:
Then |
Dirty hack detected: https://github.com/mono/mono/blob/master/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Import.cs#L274, https://github.com/mono/mono/blob/master/mcs/class/Microsoft.Build/Microsoft.Build.Evaluation/ProjectCollection.cs#L408 Bug reference: http://lists.ximian.com/pipermail/mono-bugs/2011-January/107817.html It doesn't explain exactly why the behaviour is different in FCS vs xbuild though. |
Interestingly C# uses
|
If the F# targets were installed to When invoking xbuild the code must follow a different path than programmatic access to msbuild thats the only explanation. The main question is how to resolve this? |
I absolutely agree. I suggest tracking down these paths so that we can behave the same as through xbuild. Perhaps it sets a default value for |
Ha! I patched it so it uses a better backup location: <FSharpTargets Condition="Exists('$(MSBuildBinPath)\..\..\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">$(MSBuildBinPath)\..\..\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargets> And we get the old InvalidCast exception! |
Ok, so with a better safe path (See above) everything works as long as the assembly redirects are in place, which wont happen in XS, so to fix this we need the separate process invocation or reflection based calling. How would reflection based calling work would that simulate binding redirects or ? |
I'll close this as XS doesn't use the cracker any more. |
Using either
FSharpProjectFileInfo.Parse
orchecker.GetProjectOptionsFromProjectFile
Causes a
Microsoft.Build.Exceptions.InvalidProjectFileException
to be thrown:Microsoft.Build.Exceptions.InvalidProjectFileException: /Users/dave/Projects/sv_classic_ios/sv_classic_ios/sv_classic_ios.fsproj: /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.MonoTouch.FSharp.targets: Project file could not be imported, it was being imported by /Users/dave/Projects/sv_classic_ios/sv_classic_ios/sv_classic_ios.fsproj: /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.MonoTouch.FSharp.targets could not import "$(FSharpTargets)"
at Microsoft.FSharp.Compiler.SourceCodeServices.FSharpProjectFileInfo..ctor (System.String fsprojFileName, Microsoft.FSharp.Core.FSharpOption
1 properties, Microsoft.FSharp.Core.FSharpOption
1 enableLogging) [0x000c2] in :0at Microsoft.FSharp.Compiler.SourceCodeServices.FSharpProjectFileInfo.Parse (System.String fsprojFileName, Microsoft.FSharp.Core.FSharpOption
1 properties, Microsoft.FSharp.Core.FSharpOption
1 enableLogging) [0x00001] in :0at <StartupCode$FSharp-CompilerBinding>.$LanguageService+GetProjectCheckerOptions@328.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00082] in /Users/dave/code/xamarin/monodevelop/main/external/fsharpbinding/FSharp.CompilerBinding/LanguageService.fs:336
at FSharp.CompilerBinding.LanguageService.GetProjectCheckerOptions (System.String projFilename, Microsoft.FSharp.Core.FSharpOption
1 properties) [0x00029] in /Users/dave/code/xamarin/monodevelop/main/external/fsharpbinding/FSharp.CompilerBinding/LanguageService.fs:328 at FSharp.CompilerBinding.LanguageService.GetCheckerOptions (System.String fileName, System.String projFilename, System.String source) [0x00036] in /Users/dave/code/xamarin/monodevelop/main/external/fsharpbinding/FSharp.CompilerBinding/LanguageService.fs:290 at <StartupCode$FSharp-CompilerBinding>.$LanguageService+ParseAndCheckFileInProject@351.Invoke (Microsoft.FSharp.Core.Unit unitVar) [0x00000] in /Users/dave/code/xamarin/monodevelop/main/external/fsharpbinding/FSharp.CompilerBinding/LanguageService.fs:351 at Microsoft.FSharp.Control.AsyncBuilderImpl+callA@805[FSharp.CompilerBinding.ParseAndCheckResults,Microsoft.FSharp.Core.Unit].Invoke (Microsoft.FSharp.Control.AsyncParams
1 args) [0x0002b] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr2/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/fsharp-fsharp-1f79c04/src/fsharp/FSharp.Core/control.fs:809The text was updated successfully, but these errors were encountered: