Msbuild: Build fail in msbuild source code(https://github.com/Microsoft/msbuild)

Created on 5 Apr 2017  路  6Comments  路  Source: dotnet/msbuild

I have cloned MSBuild source code from (https://github.com/Microsoft/msbuild) and followed below steps to build the project.

Building MSBuild with Visual Studio 2017

Install Visual Studio 2017. Select the following Workloads:
-.NET desktop development
- Desktop development with C++
Optional, build warnings may occur without it.
- .NET Core cross-platform development
Otional, not strictly required (yet) but used to develop .NET Core applications.
Clone the source code (see above).
Build the code using the cibuild.cmd script.
Open src/MSBuild.sln solution in Visual Studio 2017

But build is getting failed with following errors

The imported project "C:msbuildgitmsbuildpackagesNerdbank.GitVersioning1.5.46builddotnetNerdbank.GitVersioning.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. Microsoft.Build.CommandLine.UnitTests

The imported project "C:msbuildgitmsbuildpackagesNerdbank.GitVersioning1.5.46builddotnetNerdbank.GitVersioning.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. Microsoft.Build.Engine.OM.UnitTests

and also following projects are not getting loaded

Microsoft.Build
Microsoft.Build.Framework
Microsoft.Build.Tasks
Microsoft.Build.Utilities
MSBuildTaskHost

getting following error , when we try to reload above projects

C:msbuildgitmsbuildsrcBuildMicrosoft.Build.csproj : error : The imported project "C:msbuildgitmsbuildpackagesNerdbank.GitVersioning1.5.46builddotnetNerdbank.GitVersioning.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. C:msbuildgitmsbuildsrcdir.targets

Please help us on this.

Most helpful comment

Nerdbank.GitVersioning was missing in C:msbuildgitmsbuildsrc.nugetproject.json.

But Nerdbank.GitVersioning was available in a C:msbuildgit2msbuildsrc.nugetproject.json in a another MSBuild branch which I cloned today.

So I followed the steps given with new repository and build was successful and was able to open and build with VS2017 successfully.

Thank you very much for your excellent support and greatly appreciate your quick turnaround.

All 6 comments

Try running C:msbuildgitmsbuildcibuild.cmd

As per the instruction given to "Building MSBuild with Visual Studio 2017" , I already executed cibuild.cmd , but still having above errors when the solution is open and build from VS 2017

As you previously, instructed tried executing "dotnet restore" , but getting following error
C:msbuildgitmsbuild>dotnet restore
C:msbuildgitmsbuildbuild.proj : error MSB4057: The target "Restore" does not
exist in the project.

Please help on this.

@nadun82 please try the following:

  1. Open Developer Command Prompt for VS 2017
  2. Run cd /d C:\msbuildgit
  3. Run git clean -xfd to clean the enlistment
  4. Run cibuild.cmd --build-only to build the source code

If it fails, please attach C:\msbuildgit\msbuild_bootstrap_build-Full.log

If it succeeds, you should be able to open MSBuild.sln and build in Visual Studio 2017.

Steps have been followed accordingly and build was failed . Log file is attached. Please you may check .

msbuild_bootstrap_build-Full.zip

This is very strange. This project.json has Nerdbank.GitVersioning so when I build, I see this in my log:

 "D:\msbuild\Tools\dotnetcli/dotnet.exe" restore --legacy-packages-directory --packages D:\msbuild\packages\ "D:\msbuild\src\.nuget\project.json" (TaskId:3)
 log  : Restoring packages for D:\msbuild\src\.nuget\project.json... (TaskId:3)
 log  : Installing Microsoft.Net.Compilers 2.0.0-rc3-61110-06. (TaskId:3)
 log  : Installing Microsoft.DotNet.BuildTools.GenAPI 1.0.0-beta2-00731-01. (TaskId:3)
 log  : Installing Nerdbank.GitVersioning 1.5.46. (TaskId:3)
 log  : Installing NuSpec.ReferenceGenerator 1.4.2. (TaskId:3)
 log  : Installing xunit.runner.console 2.1.0. (TaskId:3)
 log  : Installing MicroBuild.Core 0.2.0. (TaskId:3)
 log  : Writing lock file to disk. Path: D:\msbuild\src\.nuget\project.lock.json (TaskId:3)
 log  : Generating MSBuild file D:\msbuild\src\.nuget\.nuget.nuget.targets. (TaskId:3)
 log  : Generating MSBuild file D:\msbuild\src\.nuget\.nuget.nuget.props. (TaskId:3)
 log  : Restore completed in 2420ms for D:\msbuild\src\.nuget\project.json. (TaskId:3)

However, in your log, its restoring everything ___except___ Nerdbank.GitVersioning.

 "C:\msbuildgit\msbuild\Tools\dotnetcli/dotnet.exe" restore --legacy-packages-directory --packages C:\msbuildgit\msbuild\packages\ "C:\msbuildgit\msbuild\src\.nuget\project.json" (TaskId:3)
 log  : Restoring packages for C:\msbuildgit\msbuild\src\.nuget\project.json... (TaskId:3)
 log  : Installing Microsoft.Net.Compilers 2.0.0-rc3-61110-06. (TaskId:3)
 log  : Installing Microsoft.DotNet.BuildTools.GenAPI 1.0.0-beta2-00731-01. (TaskId:3)
 log  : Installing NuSpec.ReferenceGenerator 1.4.2. (TaskId:3)
 log  : Installing xunit.runner.console 2.1.0. (TaskId:3)
 log  : Installing MicroBuild.Core 0.2.0. (TaskId:3)
 log  : Writing lock file to disk. Path: C:\msbuildgit\msbuild\src\.nuget\project.lock.json (TaskId:3)
 log  : Generating MSBuild file C:\msbuildgit\msbuild\src\.nuget\.nuget.nuget.targets. (TaskId:3)
 log  : Generating MSBuild file C:\msbuildgit\msbuild\src\.nuget\.nuget.nuget.props. (TaskId:3)
 log  : Restore completed in 41260ms for C:\msbuildgit\msbuild\src\.nuget\project.json. (TaskId:3)

Can you confirm that C:\msbuildgit\msbuild\src\.nuget\project.json contains Nerdbank.GitVersioning on your machine?

Nerdbank.GitVersioning was missing in C:msbuildgitmsbuildsrc.nugetproject.json.

But Nerdbank.GitVersioning was available in a C:msbuildgit2msbuildsrc.nugetproject.json in a another MSBuild branch which I cloned today.

So I followed the steps given with new repository and build was successful and was able to open and build with VS2017 successfully.

Thank you very much for your excellent support and greatly appreciate your quick turnaround.

Was this page helpful?
0 / 5 - 0 ratings