0

I have been trying to build a .NET project with visual studio 2017 Community on my local.

The build works fine when done using Publish option but throws below error when trying using msbuild

C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API>msbuild
Microsoft (R) Build Engine version 4.8.4084.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 2021-06-28 3:55:47 PM.
Project "C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj" on node 1 (default targets).
C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj(281,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualSt
udio\**v11.0**\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Done Building Project "C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj" (default targets) -- FAILED.
Build FAILED.
"C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj" (default target) (1) ->
  C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj(281,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\Visual
Studio\**v11.0**\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on
 disk.
    0 Warning(s)
    1 Error(s)
Time Elapsed 00:00:00.08

I have gone through various similar articles on Stackoverflow and various other sites but none of them help.

Where it is pulling v11.0 from? I don't have that value in my csproj file.

The Fabio
  • 5,369
  • 1
  • 25
  • 55
Ajay Malik
  • 13
  • 2
  • Run a clean on the whole solution but then specifically rebuild the project(s) giving you problems. Then build the whole solution again. This seems like build errors due to other things not building properly. – FernandoG Jun 28 '21 at 20:06

2 Answers2

0

Are you using correct version of MSBuild?

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
C:\Windows\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\MSBuild.exe

The path to MSBuild could be different depending on your pc

If Yes check the following example

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj /t:Clean

For more information run the following command:

 C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /?

You can also use this link

  • I am using 15.0, guess there was an older installation that was causing issues. Resolved now. Appreciate your response. Thanks. – Ajay Malik Jun 30 '21 at 13:48
0

I cleaned up my system and reinstalled msbuild and it works fine now.

Ajay Malik
  • 13
  • 2