Skip to content
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

first Build.cmd failed on windows #295

Closed
susloparovdenis opened this issue Jun 9, 2017 · 22 comments
Closed

first Build.cmd failed on windows #295

susloparovdenis opened this issue Jun 9, 2017 · 22 comments

Comments

@susloparovdenis
Copy link

I have windows10 and vs2017 with all the updates.
CheckFSharpInstallation.fsproj(19,5): error : File Microsoft.FSharp.Targets not found. Is F# correctly installed on this system?

I have Microsoft.FSharp.Targets in following locations. I am confused
image

full output:

Checking Paket version (downloading latest stable)...
Paket.exe 4.8.7 is up to date.
Paket version 4.8.7
1 second - ready.
Paket version 4.8.7
Resolving packages for group Build:
 - Octokit 0.24.0
 - FAKE 4.61.3
 - FSharp.Formatting 2.14.4
 - SourceLink.Fake 1.1.0
 - Microsoft.Net.Http 2.2.29
 - FSharpVSPowerTools.Core 2.3.0
 - FSharp.Compiler.Service 2.0.0.6
 - Microsoft.Bcl 1.1.10
 - Microsoft.Bcl.Build 1.0.21
Resolving packages for group Main:
 - FSharp.Core 4.0.0.1
Resolving packages for group Test:
 - NUnit 2.6.4
 - NUnit.Runners 2.6.4
C:\Users\dsusloparov\Google Drive\Workspace\tensorF\paket.lock is already up-to-date
4 seconds - ready.
Building project: CheckFSharpInstallation.fsproj
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe  CheckFSharpInstallation.fsproj /t:CheckFSharpInstallation /m      /p:RestorePackages="False" /p:OutputPath="C:\Users\dsusloparov\Google Drive\Workspace\tensorF" /p:Configuration="Release" /logger:Fake.MsBuildLogger+ErrorLogger,"C:\Users\dsusloparov\Google Drive\Workspace\tensorF\packages\build\FAKE\tools\FakeLib.dll"
Microsoft (R) Build Engine version 15.1.1012.6693
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 6/9/2017 2:07:13 PM.
     1>Project "C:\Users\dsusloparov\Google Drive\Workspace\tensorF\CheckFSharpInstallation.fsproj" on node 1 (CheckFSh
       arpInstallation target(s)).
     1>C:\Users\dsusloparov\Google Drive\Workspace\tensorF\CheckFSharpInstallation.fsproj(19,5): error : File Microsoft
       .FSharp.Targets not found. Is F# correctly installed on this system?
     1>Done Building Project "C:\Users\dsusloparov\Google Drive\Workspace\tensorF\CheckFSharpInstallation.fsproj" (Chec
       kFSharpInstallation target(s)) -- FAILED.

Build FAILED.

       "C:\Users\dsusloparov\Google Drive\Workspace\tensorF\CheckFSharpInstallation.fsproj" (CheckFSharpInstallation ta
       rget) (1) ->
       (CheckFSharpInstallation target) ->
         C:\Users\dsusloparov\Google Drive\Workspace\tensorF\CheckFSharpInstallation.fsproj(19,5): error : File Microso
       ft.FSharp.Targets not found. Is F# correctly installed on this system?

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.03
F# does not seem to be installed.
Please install F# (see http://fsharp.org/use/windows/ for instructions),
then run the build script again.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Exception: Build script aborted: please install F# and try again.
   at <StartupCode$FSI_0005>.$FSI_0005_Init$fsx.main@()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Fake.FSIHelper.runScriptCached@315.Invoke(Unit unitVar0) in C:\code\fake\src\app\FakeLib\FSIHelper.fs:line 323
System.Exception: Build script aborted: please install F# and try again.
   at <StartupCode$FSI_0005>.$FSI_0005_Init$fsx.main@() in C:\Users\dsusloparov\Google Drive\Workspace\tensorF\init.fsx:line 36
Stopped due to error

Build failed.
Error:
Could not find file 'C:\Users\dsusloparov\Google Drive\Workspace\tensorF\build.fsx'.


@pblasucci
Copy link
Collaborator

OK. I can confirm. This seems to be happen for me (and a few others based on some Slack comments). It looks like the code for detecting the presence of F# is reporting false negatives in some case.

@dsyme
Copy link
Contributor

dsyme commented Jun 9, 2017

@pblasucci I'll fix this now (was about to make the changes to remove SourceLink)

@dsyme
Copy link
Contributor

dsyme commented Jun 9, 2017

@susloparovdenis @pblasucci I can't repro this. Which prompt are you running from - a VS2017 developer prompt or...

Could you try again now #296 has been merged? thanks

@pblasucci
Copy link
Collaborator

@dsyme just tried again... same results. I'm using a bog standard instance of cmd.exe.

@pblasucci
Copy link
Collaborator

pblasucci commented Jun 9, 2017

OK. I found a clue. It's looking in:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\v\FSharp\Microsoft.FSharp.Targets

Notice the \v\ ? That should probably be \v15.0\ (or at least some number after the v). Not sure how to fix this (yet). I mean, what would cause the CheckFSharpInstallation.fsproj to have an empty value for $(VisualStudioVersion)?

@dsyme
Copy link
Contributor

dsyme commented Jun 9, 2017

Yes, VisualStudioVersion is not set, I have no idea why. I thought it was always set.

@dsyme
Copy link
Contributor

dsyme commented Jun 9, 2017

Can you try ToolsVersion="15.0" at the top of the project files? Just wondering.

@dsyme
Copy link
Contributor

dsyme commented Jun 9, 2017

@pblasucci Note that using a VS2017 developer command prompt will work. But we should make it work from cmd.exe as well

@pblasucci
Copy link
Collaborator

pblasucci commented Jun 9, 2017

Changing the tools version did not alter the behavior. And, just to confirm, the VS2017 developer command prompt does work. This is due to the dev prompt is putting the Visual Studio version into an environment variable (which is absent in the vanilla prompt). Also, as an aside, even though the dev prompt works correctly, it emits a (spurious) warning about F# Tools not being installed... but one issue at a time. :-)

@dsyme
Copy link
Contributor

dsyme commented Jun 9, 2017

Do you know which MSBUILD is being run? When I use

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe

it works but when I use the very old

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe

it doesn't. I assume FAKE is in charge of choosing the right MSBuild, but I thought that FAKE 4.61.3 had an appropriate fix to always find the right version in all circumstances

@pblasucci
Copy link
Collaborator

Seems it's using

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe

@dsyme
Copy link
Contributor

dsyme commented Jun 9, 2017

Seems it's using C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe

Does it work when you invoke that MSBUILD.EXE directly?

BTW here's a relevant FAKE issue: fsprojects/FAKE#1442. And here's the list of search paths it uses to find MSBuild.exe: https://github.com/fsharp/FAKE/blob/master/src/app/FakeLib/MSBuildHelper.fs#L25

@pblasucci
Copy link
Collaborator

No luck. Invoking MSBuild.exe directly causes the same result.

@dsyme
Copy link
Contributor

dsyme commented Jun 9, 2017

How about if you add

  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

to CheckFSharpInstallation.fsproj at the top of the file

@dsyme
Copy link
Contributor

dsyme commented Jun 9, 2017

OK, adding the Microsoft.Common.Props entry fixes this for me

(I can repro this now. I was not focusing on CheckFSharpInstallation.fsproj - I was building the generated project (which has the Microsoft.Common.props entry))

@pblasucci
Copy link
Collaborator

pblasucci commented Jun 9, 2017

Ding! Ding! Ding! We have a winner! Adding that sorted it.

However, I still get the following (spurious) warning:

C:\Program Files\Git\cmd\git.exe remote -v
System.Exception: Build script aborted: please install F# and try again.
   at <StartupCode$FSI_0005>.$FSI_0005_Init$fsx.main@() in C:\Projects\ProjectScaffold\init.fsx:line 36
Stopped due to error

However, everything does build and run correctly..

@dsyme
Copy link
Contributor

dsyme commented Jun 9, 2017

Print the exception being caught here:

let checkFSharpInstallation () =
  try
    MSBuildRelease "." "CheckFSharpInstallation" ["CheckFSharpInstallation.fsproj"] |> ignore
    true
  with e ->
    false

@dsyme
Copy link
Contributor

dsyme commented Jun 9, 2017

Make sure you're starting from clean each time, i.e.

git reset --hard master
git clean -xfd .

@pblasucci
Copy link
Collaborator

I'd been starting clean each time. But printing the caught error seems to have fixed everything. No idea why/how, though

O_o

Anyway, at least we have the fixes... now someone just needs to prepare PR.

@dsyme
Copy link
Contributor

dsyme commented Jun 9, 2017

Done: #297

@dsyme dsyme closed this as completed Jun 9, 2017
@dsyme
Copy link
Contributor

dsyme commented Jun 9, 2017

@pblasucci Could you verify? There is no printing of the caught error in that PR (did you actually get an error printed?)

@pblasucci
Copy link
Collaborator

pblasucci commented Jun 9, 2017

Yup. Everything looks peachy now! 👍

There's no error being displayed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants