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

MSBuild of fsproj fails with: error MSB4057: The target "Build" does not exist in the project. #12419

Closed
colethecoder opened this issue Nov 18, 2021 · 3 comments
Labels

Comments

@colethecoder
Copy link

An fsproj that builds correctly on MSBuild 16 (the version with Visual Studio 2019) fails to build on MSBuild 17 (the version with Visual Studio 2022).

I found this error whilst investigating why the csproj that referenced this project in our solution was failing to build because it was unable to find types from the fsproj. On isolating just the fsproj and running MSBuild against that I received the error:

MSB4057: The target "Build" does not exist in the project.

Repro steps

The fsproj is a .Net Standard 2.0 project. The fsproj looks like:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  </PropertyGroup>
  <ItemGroup>
    <None Include="paket.references" />
    <Compile Include="Schema.fs" />
    <Compile Include="Parser.fs" />
    <Compile Include="Execution.fs" />
    <Compile Include="Do.fs" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\MMS.ParserCombinators\MMS.ParserCombinators.fsproj" />
  </ItemGroup>
  <Import Project="..\..\..\.paket\Paket.Restore.targets" />
</Project>

I'm running the command:

MSBuild.exe /bl:W:\stuff\tmpFC82.tmp.binlog /clp:ForceConsoleColor /m:8 /nodeReuse:False /p:RestorePackages=False /p:Optimize=True /p:DebugSymbols=True /p:Configuration=Release /restore /t:Build /v:m "W:\stuff\src\mms\MMS.Text.Interpolate\MMS.Text.Interpolate.fsproj"

We have the Visual Studio Build Tools for 2019 and 2022 installed on the server and both have the F# compiler installed.

If I run identical commands against the same code using 2019 it succeeds and 2022 it returns this failure.

Expected behavior

The build to run and succeed

Actual behavior

MSB4057: The target "Build" does not exist in the project.

Known workarounds

I attempted adding <FSharpPreferNetFrameworkTools>true</FSharpPreferNetFrameworkTools> but it made no difference.

Related information

  • Windows Server 2019
@colethecoder
Copy link
Author

In addition I've noticed there are no Fsharp folders under:

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft

There are under:

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft

@colethecoder
Copy link
Author

This seems to be an issue with the Build Tools installation for VS2022, installing Community edition results in an MSBuild that recognises the F# projects and builds correctly.

@dsyme
Copy link
Contributor

dsyme commented Mar 3, 2022

Duplicate of #12467

@dsyme dsyme marked this as a duplicate of #12467 Mar 3, 2022
@dsyme dsyme closed this as completed Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants