fsprojects / ProjectScaffold

A prototypical .NET solution (file system layout and tooling), recommended for F# projects
http://fsprojects.github.io/ProjectScaffold
The Unlicense
516 stars 153 forks source link

Couldn't build on Windows 10 using build.cmd #283

Closed nojaf closed 7 years ago

nojaf commented 7 years ago

Description

I was unable to build the entire project by running the build.cmd file. MSBuild was unable to import the FSharpTargetsPath.

Repro steps

Please provide the steps required to reproduce the problem

  1. Create new project

  2. Run build.cmd

Expected behavior

Newly create project builds.

Actual behavior

MSBuild error that certain targets cannot be found.

Known workarounds

Replace

<Choose>
    <When Condition="'$(VisualStudioVersion)' == '11.0'">
      <PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
        <FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
      </PropertyGroup>
    </When>
    <Otherwise>
      <PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
        <FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
      </PropertyGroup>
    </Otherwise>
  </Choose>-->
    <!--<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.Targets')">
        <FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
      </PropertyGroup>
  <PropertyGroup>

With

  <PropertyGroup>
    <FSharpTargetsPath>C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.targets</FSharpTargetsPath>
  </PropertyGroup>
  <Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />

For src and test fsproj files.

Related information

nojaf commented 7 years ago

I tried the same thing using a Visual Studio Command Prompt and it worked fine. So I'm guessing I'm missing some stuff on my PATH variable. Any ideas?

jimmydburr commented 7 years ago

@nojaf I think you're on the right path, so to speak. There is a file called vcvarsall.bat located in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC on my machine. Running this in a regular CMD window will setup all the vars you need to do a build from the command line.

cdrnet commented 7 years ago

Depending on vcvarsall.bat being called would be a major regression that should be fixed though.

dsyme commented 7 years ago

@cdrnet @jimmydburr @nojaf Your input on the linked bug would be appreciated (workarounds, analysis etc.)

nojaf commented 7 years ago

Well my concrete issue was the fact that the msbuild target was not found. Maybe some new logic should be added that looks for possible locations of the target. I'm really a novice in all this so perhaps the build should fail early when the target cannot be resolved.

dsyme commented 7 years ago

I believe this has been fixed by using the latest FAKE. It compiles OK for me on Windows