Last updated: September 11, 2025
MSB4019 occurs when MSBuild cannot locate the .props/.targets files it's trying to import.
The root cause is typically missing required workloads or using the wrong MSBuild path.
- C++: Install Desktop development with C++ workload
- Web: Install ASP.NET and web development workload
- SQL (SSDT): Install Data storage and processing → SQL Server Data Tools
- Build: Use Visual Studio's MSBuild (Developer Command Prompt recommended, VS 2022 defaults to 64-bit)
Table of Contents
Identifying Error Symptoms
Common MSB4019 error patterns include:
error MSB4019: The imported project 'C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v170\Microsoft.Cpp.Default.props' was not found.
error MSB4019: The imported project '...\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets' was not found.
error MSB4019: The imported project '...\Microsoft.Data.Tools.Schema.SqlTasks.targets' was not found.
Start by noting the missing file name in the error message. Different workloads/tools provide different files.
Root Cause Analysis
- Missing essential workloads (C++/Web/SSDT)
- Building with non-VS MSBuild (path issues)
- Hard-coded paths in
.vcxproj/.csprojfiles (e.g.,VSToolsPath,VisualStudioVersion) - Missing target files on CI/build servers
Solution Methods
Method 1: Installing Required Components
Installation Steps
- Launch Visual Studio Installer from Start menu → Click Modify on your installed Visual Studio
- Select required items in the Workloads tab:
- C++: Desktop development with C++
- Web: ASP.NET and web development
- SQL (SSDT): Data storage and processing → SQL Server Data Tools
- Legacy toolsets if needed (
v142/v141/v140): Add corresponding MSVC v14x from Individual components
- Complete installation with the Modify button
Method 2: Using the Correct MSBuild
Build using Visual Studio's MSBuild (Developer Command Prompt recommended). Visual Studio 2022 uses 64-bit MSBuild by default. Developer Command Prompt automatically adds ...\MSBuild\Current\Bin to your PATH.
msbuild YourSolution.sln -m -v:minimal
"%ProgramFiles%\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe" YourSolution.sln
"%ProgramFiles%\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe" YourSolution.sln
# PowerShell example with vswhere:
$vs = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" `
-latest -products * -requires Microsoft.Component.MSBuild -property installationPath
& "$vs\MSBuild\Current\Bin\MSBuild.exe" YourSolution.sln -m -v:minimal
Note: dotnet build is recommended for SDK-style projects only. Legacy/non-SDK projects (especially C++, web apps, SQL projects) require VS MSBuild. .sqlproj (SSDT) cannot be built reliably with dotnet build.
Method 3: Fixing Project Files
Avoid hard-coded paths and use standard variables instead. Check for VisualStudioVersion or VSToolsPath values hard-coded to old versions (e.g., v14.0) and update them to use variables.
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Reference: VS 2022's default location is
C:\Program Files\Microsoft Visual Studio\2022\Edition\MSBuild\Microsoft\VC\v170\Microsoft.Cpp.Default.props.
If error logs show Program Files (x86)\MSBuild\Microsoft.Cpp\..., this may indicate legacy toolsets or incorrect hard-coded imports.
Web Project Import Example:
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets"
Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\WebApplications\Microsoft.WebApplication.targets"
Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\WebApplications\Microsoft.WebApplication.targets')" />
Method 4: Build Environment Verification
Verify that your current MSBuild path points to the VS folder.
where msbuild
Correct Path Example: C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe
Verification Steps
- Identified the missing filename from the error message
- Installed the corresponding workload/tools
- Built using VS MSBuild
- Cleaned up project
<Import>statements with standard variables - Build completes without MSB4019
msbuild YourSolution.sln -t:Clean msbuild YourSolution.sln -restore -m -v:minimal
For legacy projects using packages.config, restore with one of:
msbuild YourSolution.sln -t:Restore -p:RestorePackagesConfig=true nuget restore YourSolution.sln
Note: nuget restore is the most reliable for packages.config-based projects.
Frequently Asked Questions
Q1. Can I just set VCTargetsPath manually?
This works temporarily, but the recommended solution is to properly install the related workloads.
Q2. What about CI/CD environments?
Install Visual Studio Build Tools 2022 with required workloads (or specific components like Web development build tools). NuGet packages like MSBuild.Microsoft.VisualStudio.Web.targets are workarounds—proper workload installation is the real solution.
Q3. Can I use dotnet build?
Recommended for SDK-style projects. For legacy/non-SDK projects and .sqlproj, use VS MSBuild instead.
Q4. Specific files keep missing?SqlTasks.targets → Install SSDT, WebApplication.targets → Install web workload. In CI, ensure the proper workload/component is added.
References
- MSB4019 Error — Microsoft Learn
- Visual Studio Workload Installation — Microsoft Learn
- Visual Studio Installation Guide (Workloads tab examples)
Pro Tip: Once resolved, share this solution with your team to prevent recurring issues.
0 Comments