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

Error: The target "Build" does not exist in the project #349

Open
alexandru opened this issue Aug 17, 2019 · 8 comments
Open

Error: The target "Build" does not exist in the project #349

alexandru opened this issue Aug 17, 2019 · 8 comments

Comments

@alexandru
Copy link

On MacOS the initial build.sh fails with this:

/usr/local/Cellar/mono/6.0.0.319/lib/mono/msbuild/15.0/bin/MSBuild.dll /bl:/var/folders/r1/xm_0s3y11td6zwk4mx8nplrw0000gn/T/tmpixxlW5.tmp.binlog /p:RestorePackages=False /p:Optimize=True /p:DebugSymbols=True /p:Configuration=Release /t:Build /v:q MyProject.sln
/Users/alex/Projects/MyProject/src/MyProject/MyProject.fsproj : error MSB4057: The target "Build" does not exist in the project.
/Users/alex/Projects/MyProject/src/MyProject/MyProject.fsproj : error MSB4057: The target "Build" does not exist in the project.
/Users/alex/Projects/MyProject/src/MyProject/MyProject.fsproj : error MSB4057: The target "Build" does not exist in the project.
/Users/alex/Projects/MyProject/src/MyProjectConsole/MyProjectConsole.fsproj : error MSB4057: The target "Build" does not exist in the project.
/Users/alex/Projects/MyProject/src/MyProjectConsole/MyProjectConsole.fsproj : error MSB4057: The target "Build" does not exist in the project.
: /Users/alex/Projects/MyProject/src/MyProject/MyProject.fsproj(0,0): error MSB4057: The target "Build" does not exist in the project.
: /Users/alex/Projects/MyProject/src/MyProjectConsole/MyProjectConsole.fsproj(0,0): error MSB4057: The target "Build" does not exist in the project.
Finished (Failed) 'MSBuild' in 00:00:02.1028417
Finished (Failed) 'Build' in 00:00:02.1050855
@Thorium
Copy link
Member

Thorium commented Oct 22, 2019

To found the issue, you can created your own Build-target to the fsproj-file first:

<Target Name="Build">
	<Message Text="Ext = $(MSBuildExtensionsPath)" />
	<Message Text="Tools = $(MSBuildToolsVersion)" />
	<Message Text="msb32 = $(MSBuildExtensionsPath32)" />
	<Message Text="targ = $(TargetFrameworkIdentifier)" />
	<Message Text="fs = $(FSharpTargetsPath)" />
	<Message Text="vs = $(VisualStudioVersion)" />
</Target>  

The issue is probably that there is a condition saying something like

  <PropertyGroup Condition="'$(VisualStudioVersion)' != '11.0'">
    <FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
  </PropertyGroup>

but with recent Visual Studio the condition is not met or the path is actually somewhere else,
like in VisualStudio\v$(MSBuildToolsVersion)\FSharp\ and not in VisualStudio\v$(VisualStudioVersion)\FSharp\ so as a quick fix
you can fallback it to something else like

  <PropertyGroup Condition="'$(VisualStudioVersion)' != '11.0' And Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\')">
    <FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(VisualStudioVersion)' != '11.0' And Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(MSBuildToolsVersion)\FSharp\')">
    <FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(MSBuildToolsVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
  </PropertyGroup>  

@daz10000
Copy link

Second this - a fresh pull of the project, ran once to enter project details and then ./build.sh (windows, git) gives output below

RUnning

$ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.201
 Commit:    b1768b4ae7

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.201\

Host (useful for support):
  Version: 3.1.3
  Commit:  4a9f85e9f8

.NET Core SDKs installed:
  2.2.401 [C:\Program Files\dotnet\sdk]
  3.0.100 [C:\Program Files\dotnet\sdk]
  3.1.100 [C:\Program Files\dotnet\sdk]
  3.1.201 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
$ ./build.sh
  Restore completed in 26.94 ms for C:\extproj\ProjectScaffold\build.proj.
  Restore completed in 30.53 ms for C:\extproj\ProjectScaffold\build.proj.
The last restore is still up to date. Nothing left to do.
run All
Building project with version: LocalBuild
Shortened DependencyGraph for Target All:
<== All
   <== NuGet
      <== GenerateDocs
         <== RunTests
            <== CopyBinaries
               <== Build
                  <== Restore
                     <== AssemblyInfo
                        <== Clean
         <== ReferenceDocs
            <== Docs
               <== CleanDocs

The running order is:
Group - 1
  - Clean
Group - 2
  - AssemblyInfo
Group - 3
  - Restore
Group - 4
  - Build
Group - 5
  - CopyBinaries
Group - 6
  - RunTests
Group - 7
  - CleanDocs
Group - 8
  - Docs
Group - 9
  - ReferenceDocs
Group - 10
  - GenerateDocs
Group - 11
  - NuGet
Group - 12
  - All
Starting target 'Clean'
Finished (Success) 'Clean' in 00:00:00.0071921
Starting target 'AssemblyInfo'
Finished (Success) 'AssemblyInfo' in 00:00:00.0462503
Starting target 'Restore'
Starting task 'DotNet:restore': fss.sln
If you encounter msbuild errors make sure you have copied the required SDKs, see https://github.com/Microsoft/msbuild/issues/1697
C:\extproj\ProjectScaffold> "C:\Program Files\dotnet\dotnet.EXE" msbuild /version /nologo (In: false, Out: true, Err: true)
16.5.0.12403
C:\extproj\ProjectScaffold> "C:\Program Files\dotnet\dotnet.EXE" restore fss.sln /nodeReuse:False "/bl:C:\Users\daz\AppData\Local\Temp\tmpB8B5.tmp.binlog" (In: false, Out: false, Err: false)
C:\Program Files\dotnet\sdk\3.1.201\MSBuild.dll -nologo -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\3.1.201\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\3.1.201\dotnet.dll -maxcpucount -target:Restore -verbosity:m /bl:C:\Users\daz\AppData\Local\Temp\tmpB8B5.tmp.binlog /nodeReuse:False fss.sln
  Restore completed in 45.27 ms for C:\extproj\ProjectScaffold\tests\fss.Tests\fss.Tests.fsproj.
  Restore completed in 44.09 ms for C:\extproj\ProjectScaffold\src\fssConsole\fssConsole.fsproj.
  Restore completed in 44.09 ms for C:\extproj\ProjectScaffold\src\fss\fss.fsproj.
Finished (Success) 'DotNet:restore' in 00:00:02.5443836
Finished (Success) 'Restore' in 00:00:02.5454715
Starting target 'Build'
Starting task 'MSBuild': fss.sln
> "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe" /version /nologo (In: false, Out: true, Err: true)
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe fss.sln /t:Build /m /nodeReuse:False /v:q /p:RestorePackages=False /p:Optimize=True /p:DebugSymbols=True /p:Configuration=Release "/bl:C:\Users\daz\AppData\Local\Temp\tmpC27A.tmp.binlog"
C:\extproj\ProjectScaffold> "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe" fss.sln /t:Build /m /nodeReuse:False /v:q /p:RestorePackages=False /p:Optimize=True /p:DebugSymbols=True /p:Configuration=Release "/bl:C:\Users\daz\AppData\Local\Temp\tmpC27A.tmp.binlog" (In: false, Out: false, Err: false)
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe /bl:C:\Users\daz\AppData\Local\Temp\tmpC27A.tmp.binlog /m /nodeReuse:False /p:RestorePackages=False /p:Optimize=True /p:DebugSymbols=True /p:Configuration=Release /t:Build /v:q fss.sln
C:\extproj\ProjectScaffold\src\fss\fss.fsproj : error MSB4057: The target "Build" does not exist in the project.
C:\extproj\ProjectScaffold\src\fssConsole\fssConsole.fsproj : error MSB4057: The target "Build" does not exist in the project.
C:\extproj\ProjectScaffold\src\fssConsole\fssConsole.fsproj : error MSB4057: The target "Build" does not exist in the project.
C:\extproj\ProjectScaffold\src\fss\fss.fsproj : error MSB4057: The target "Build" does not exist in the project.
C:\extproj\ProjectScaffold\src\fss\fss.fsproj : error MSB4057: The target "Build" does not exist in the project.
: C:\extproj\ProjectScaffold\src\fss\fss.fsproj(0,0): error MSB4057: The target "Build" does not exist in the project.
: C:\extproj\ProjectScaffold\src\fssConsole\fssConsole.fsproj(0,0): error MSB4057: The target "Build" does not exist in the project.
Finished (Failed) 'MSBuild' in 00:00:01.0206622
Finished (Failed) 'Build' in 00:00:01.0223196

---------------------------------------------------------------------
Build Time Report
---------------------------------------------------------------------
Target          Duration
------          --------
Clean           00:00:00.0032040
AssemblyInfo    00:00:00.0461958
Restore         00:00:02.5453931
Build           00:00:01.0222261   (Exception of type 'Fake.DotNet.MSBuildException' was thrown.)
CopyBinaries    00:00:00           (skipped)
RunTests        00:00:00           (skipped)
CleanDocs       00:00:00           (skipped)
Docs            00:00:00           (skipped)
ReferenceDocs   00:00:00           (skipped)
GenerateDocs    00:00:00           (skipped)
NuGet           00:00:00           (skipped)
All             00:00:00           (skipped)
Total:          00:00:03.7738034
Status:         Failure
---------------------------------------------------------------------
Script reported an error:
-> BuildFailedException: Target 'Build' failed.
-> One or more errors occurred. (Exception of type 'Fake.DotNet.MSBuildException' was thrown.)
-> MSBuildException: Exception of type 'Fake.DotNet.MSBuildException' was thrown.
Hint: To further diagnose the problem you can run fake in verbose mode `fake -v run ...` or set the 'FAKE_DETAILED_ERRORS' environment variable to 'true'
Hint: Could not find a version in your paket.dependencies file, consider adding 'version 5.245.1' at the top of your dependencies file (C:\extproj\ProjectScaffold\paket.dependencies).
Read https://github.com/fsharp/FAKE/issues/2193 for details.
Performance:
 - Cli parsing: 277 milliseconds
 - Packages: 206 milliseconds
 - Script analyzing: 75 milliseconds
 - Script running: 3 seconds
 - Script cleanup: 9 milliseconds
 - Runtime: 6 seconds

@daz10000
Copy link

As a workaround, there is commented out section of the build target in the generated template. If you uncomment that, and comment out the active portion like so, it seems to work. Suggest fixing the template to use the commented out version? Not sure why it's like that. Happy to send a PR if people agree that's preferable? Looking at it, it seems like the dotnet build process is working for me but not the MSBuild call. Your experience might vary depending on which SDK you have installed. My 2020 motto is torch .Netxxx support - it's holding everyone back at this point, but YMMV.

Target.create "Build" (fun _ ->
    solutionFile
    |> DotNet.build (fun p ->
        { p with
            Configuration = buildConfiguration })
    (*

    let setParams (defaults:MSBuildParams) =
        { defaults with
            Verbosity = Some(Quiet)
            Targets = ["Build"]
            Properties =
                [
                    "Optimize", "True"
                    "DebugSymbols", "True"
                    "Configuration", configuration
                ]
         }
    MSBuild.build setParams solutionFile
    *)
)```

@Krzysztof-Cieslak
Copy link
Member

I don't think this project is maintained any more - I'd recommend using https://github.com/TheAngryByrd/MiniScaffold or https://github.com/ionide/Waypoint instead.

Hey, @forki maybe we should somehow formalize that by putting huge info in the readme?

@daz10000
Copy link

That's too bad - was trying to upgrade an old project based on this and hoping I could drop a fresh checkout onto the old one. That's part of the problem with using scaffolds etc - it's a fast way to get started but you kind of get locked in to the infrastructure. Right now the project and tests themselves build with just vanilla dotnet tooling but all the other housekeeping like release notes, and packaging and docs depend on getting some now spider web encrusted scripts updated.

@wallymathieu
Copy link
Member

Or perhaps revamp this project?

@daz10000
Copy link

daz10000 commented May 16, 2020 via email

@wallymathieu
Copy link
Member

Looks like there hasn't been any accepted pull requests in a while, so let's ask about in the f# projects channel.

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

5 participants