1. Build a .NET project.
- Download Build Tools for Visual Studio 2022. (Scroll down to the bottom of the page.)
- Install .NET SDKs for Visual Studio.
- Select a MSBuild.exe location:
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin or C:\Program Files\Microsoft Visual Studio\2022\Professional\Msbuild\Current\Bin
- Execute the command below to build a solution.
"C:\Program Files\Microsoft Visual Studio\2022\Professional\Msbuild\Current\Bin\MSBuild.exe" "../MySolution.sln" -restore -p:RestorePackagesConfig=true
2. Log build errors to a file.
- Execute the command below to export errors to the Build.log file.
"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 the Build.log file and search for “errors” text.
3. Hide build warnings.
- Execute the command below to hide warnings and normal messages, but still show the final build result summary, including “Build succeeded” or “Build FAILED.”
"C:\Program Files\Microsoft Visual Studio\2022\Professional\Msbuild\Current\Bin\MSBuild.exe" "./MySolution.sln" -restore -p:RestorePackagesConfig=true -p:StopOnFirstFailure=true /clp:Summary;ErrorsOnly
4. 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 ToolsVersion to 17.0.
<Project DefaultTargets="Build" ToolsVersion="17.0">
- Find VisualStudioVersion element and set its value to 17.0.
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">17.0</VisualStudioVersion>
- Find Import Project=”$(MSBuildExtensionsPath32) … Microsoft.WebApplication.targets text and set Condition to false.
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
(Visited 43 times, 1 visits today)