Tag Archives: MSBuild

How to Use MSBuild

1. Fixing “Microsoft.WebApplication.targets was not found” issue.
    • Download vs_BuildTools.exe.
    • Open Command Prompt.
    • Execute the command below.
      vs_BuildTools.exe --add Microsoft.VisualStudio.
      Workload.WebBuildTools --passive
    • Open .csproj or .vbproj file using Notepad.
    • Find Project element and set
      <Project DefaultTargets="Build" ToolsVersion="17.0">
    • Find VisualStudioVersion element and set
      <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">17.0</VisualStudioVersion>
    • FindĀ Import Project=”$(MSBuildExtensionsPath32) … Microsoft.WebApplication.targets text and set
      <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

       

     

    2. Finding build errors.
    • Execute the command below.
      "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe" /property:Configuration=Release "YourSolution.sln" -restore -p:RestorePackagesConfig=true > Build.log

       

    • Open Build.log file and search for “errors” text.