moq/labs

Does not compile in VS Community 2017 - The target "GitVersion" does not exist in the project

navyjax2 opened this issue · 4 comments

If you simply download the ZIP file, extract to a folder, double-click the .sln file to run it in Visual Studio, then right-click "Solution (Moq) (3 projects)" at the top and do a Rebuild Solution, you get:

1>------ Rebuild All started: Project: Moq, Configuration: Debug Any CPU ------
1>U:\Visual Studio 2017\Projects\Moq\build\GitVersion.props(14,109): error MSB4057: The target "GitVersion" does not exist in the project.
1>Done building project "Moq.csproj" -- FAILED.
1>U:\Visual Studio 2017\Projects\Moq\build\GitVersion.props(14,109): error MSB4057: The target "GitVersion" does not exist in the project.
1>Done building project "Moq.csproj" -- FAILED.
2>------ Rebuild All started: Project: Moq.Tests, Configuration: Debug Any CPU ------
3>------ Rebuild All started: Project: Moq.Tests.VisualBasic, Configuration: Debug Any CPU ------
========== Rebuild All: 0 succeeded, 3 failed, 0 skipped ==========

With 2 errors in the Error List:
Severity Code Description Project File Line Suppression State
Error MSB4057 The target "GitVersion" does not exist in the project. Moq U:\Visual Studio 2017\Projects\Moq\build\GitVersion.props 14
Error MSB4057 The target "GitVersion" does not exist in the project. Moq U:\Visual Studio 2017\Projects\Moq\build\GitVersion.props 14

I don't have "Git" installed, and this could be why, but which version am I supposed to install, and how? NuGet? Compile it from GitHub? Installer? Which version do I need?

Resolved issue by using NuGet Package Manager to download Moq v4.9.0, with its dependencies, from nuget.org via Visual Studio directly into my Unit Test project. Did not bother to compile version from GitHub.

stakx commented

@navyjax2: Seems like you reported at the wrong repo. If you're talking about Moq v4, visit https://github.com/moq/moq4. This here repository is for Moq v5 (which is still being developed).

That being said you appear to have run into a failed NuGet package restore. Should've been easy enough to resolve by triggering the Build once more, or perhaps by reopening the solution. That's quite possibly just one of the usual VS glitches.

If you just want to use Moq (and not actually modify / bugfix / develop with its source) then consuming the precompiled Moq NuGet package is definitely the right way to go.

kzu commented

This is something I should improve in this repo anyway, I think... Will keep it open for now

Yeah, I think I just needed Moq v4, instead, since 5 is obviously still under development. Once I consumed v4 via NuGet install, I was fine. But like kzu said, it's valid to ensure that Git dependencies are taken care of.