Azure Pipelines: MSB4019 "The imported project ... was not found" (WebApplication.targets, SqlTasks.targets)
A classic ASP.NET web application project imports Microsoft.WebApplication.targets, and a SQL Server database project imports Microsoft.Data.Tools.Schema.SqlTasks.targets. Both files are installed with Visual Studio or the Visual Studio Build Tools, not with the .NET SDK. When the project is built with dotnet build, or on an agent without them, MSBuild looks for the file where it is not and stops with MSB4019.
When the failing build is a pull request's build validation, the pull request waits on it: Azure DevOps Pull Requests, a plugin for JetBrains IDEs, lists the pull request's branch policies with their state in Rider, and with Pro runs a failed build policy again once the fix is pushed. Get it on JetBrains Marketplace
What it looks like
error MSB4019: The imported project "C:\Program Files\dotnet\sdk\8.0.x\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\WebApplications\Microsoft.WebApplication.targets", which evaluated to "...", is correct, and that the file exists on disk.- For a database project, the same message names
Microsoft.Data.Tools.Schema.SqlTasks.targetsunder...\Microsoft\VisualStudio\v17.0\SSDT\. - Read the folder at the start of the path.
dotnet\sdk\means the .NET SDK's MSBuild ran it, through the .NET Core task or a script withdotnet build; its extensions folder is inside the SDK, where these targets never are. A Visual Studio folder means Visual Studio's MSBuild ran it, but without the workload that installs the file. In the .NET Core task the error comes before Dotnet command failed with non-zero exit code.
On Microsoft-hosted agents: build with Visual Studio's MSBuild
- The Windows images
windows-2022,windows-2025andwindows-2025-vs2026carry Visual Studio Enterprise with the ASP.NET and web development workload and the SQL Server Data Tools component, by the component lists in their readmes in the runner-images repository. So both targets are there when the build goes through Visual Studio's MSBuild: the Visual Studio Build task (VSBuild@1) or the MSBuild task (MSBuild@1), not the .NET Core task. - A minimal job for a classic web project:
pool: vmImage: windows-2022 steps: - task: NuGetCommand@2 inputs: restoreSolution: '**/*.sln' - task: VSBuild@1 inputs: solution: '**/*.sln' platform: 'Any CPU' configuration: 'Release' - The Ubuntu and macOS images have no Visual Studio. A classic ASP.NET project targets .NET Framework, so build it on a Windows image.
On a self-hosted agent: the Build Tools workloads
- The Visual Studio Build Tools installer has a workload for each file (Microsoft's list of Build Tools workloads): Web development build tools,
Microsoft.VisualStudio.Workload.WebBuildTools, with the MSBuild tasks and targets for web applications, and Data storage and processing build tools,Microsoft.VisualStudio.Workload.DataBuildTools, for SQL Server database projects. - For example
vs_buildtools.exe --add Microsoft.VisualStudio.Workload.WebBuildTools --add Microsoft.VisualStudio.Workload.DataBuildTools --includeRecommended --quiet --wait, or add them to an installed copy from the Visual Studio Installer. Then restart the agent so it reports its new capabilities, and build with the Visual Studio Build or MSBuild task.
A database project: the SDK-style format
- Microsoft's newer format for SQL projects uses the
Microsoft.Build.Sqlproject SDK, builds withdotnet buildand runs on .NET 8 or later on any platform, including a Linux agent (Microsoft's overview of SQL database projects). Converting the.sqlprojremoves the need for the SSDT targets; support for this format in Visual Studio is still in preview, so check that the people who edit the project can open it.
The package with copies of the targets
- Older answers suggest the
MSBuild.Microsoft.VisualStudio.Web.targetsNuGet package, which carries copies of the web targets sodotnet buildcan find them. It is not published by Microsoft, its newest version is 14.0.0.3, the Visual Studio 2015 targets, and it does not cover database projects. Visual Studio's own MSBuild on a Windows agent is the cleaner fix.
Azure DevOps pull requests in IntelliJ IDEA and Rider
Azure DevOps Pull Requests, a plugin by Lesstep for JetBrains IDEs 2024.1 or later and Android Studio, reads the organization, project and repository from your git remote and lists the pull requests that wait for your review in an IDE tool window, on Azure DevOps Services and on Azure DevOps Server. It shows the branch policies of a pull request with their state, so a required build that has not passed is next to its pull request, and with Pro you run a failed or expired build policy again from there. The review inbox is free; voting, commenting, completing and creating are Pro, with a 30-day trial.
Get it on JetBrains Marketplace
Azure DevOps, Azure Pipelines, .NET, ASP.NET, SQL Server and Visual Studio are trademarks of Microsoft Corporation; IntelliJ IDEA and Rider are trademarks of JetBrains s.r.o. This page is not affiliated with or endorsed by Microsoft or JetBrains.
More: MSB3644: the reference assemblies were not found · Dotnet command failed with non-zero exit code · no agent satisfies the demands · 日本語