Error MSB4226 Microsoft.TextTemplating.targets not imported


You have a project that is using text templating (such as for auto-incrementing the version number) and you’re upgrading to a new version of Visual Studio. When you open the project, you get error messages about not being able to import the Microsoft.TextTemplating.targets project:

Project “…\v16.0\TextTemplating\Microsoft.TextTemplating.targets” was not imported by “…SomeProject.csproj” at (7,3), due to the file not existing.

The error might appear with slightly different wording:

MSB4226 The imported project “…\v16.0\TextTemplating\Microsoft.TextTemplating.targets” was not found

The import project path in the .csproj file is wrong.


Microsoft.TextTemplating.targets is located in the Visual Studio installation directory. If you hardcoded the Visual Studio version number in the import path, then when you try to open the project in a different version of Visual Studio, the import path will be pointing to a non-existent directory.

To fix this, edit your project .csproj file and look for the Microsoft.TextTemplating.targets import project line:

<Project Sdk="Microsoft.NET.Sdk">
    <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v16.0\TextTemplating\Microsoft.TextTemplating.targets" />
    <!-- rest of file -->
Code language: HTML, XML (xml)

Update the version in the path (ex: from v16.0 to v17.0):

"$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v17.0\TextTemplating\Microsoft.TextTemplating.targets"Code language: JSON / JSON with Comments (json)

Or use the VisualStudioVersion variable instead of hardcoding the version:

"$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TextTemplating\Microsoft.TextTemplating.targets"Code language: JSON / JSON with Comments (json)

Note: This variable might not be populated in older versions of Visual Studio.

2 thoughts on “Error MSB4226 Microsoft.TextTemplating.targets not imported”

  1. still not working… im getting a failure for C:\Program Files(x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsft.TextTemplating.targets” was not found.

    🙁 <- me

    • VS2015 doesn’t come with this by default. You get it by installing the Modeling SDK, which requires you to also install the VS2015 SDK (aka the Visual Studio Extensibility Tools feature).

      Here are the steps:
      1. Modify VS2015 by adding feature: Common Tools > Visual Studio Extensibility Tools

      Note: If you’re using the VS Web Installer and it fails, get the VS2015 Update 3 ISO and install using that. It’s 7 GB.

      Download link: Microsoft – VS2015.3 ISO

      2. Install VS2015 Modeling SDK

      Download link: Microsoft – VS2015 Modeling SDK

      Now you’ll see the file: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets


Leave a Reply to Maclain Wiltzer Cancel reply