The target “TransformAll” does not exist in the pr

2019-07-22 15:47发布

问题:

I want to transform my T4 templates using MSBuild, so I found this link. But when running:

msbuild solution.sln /t:TransformAll

I get the following error "The target "TransformAll" does not exist in the project".

The same happens if I try to compile a single project. No matter if I open a VS tools console or a regular console and get the MSBuild path.

What am I missing?

The following is the output I get (I'm affraid that it is in spanish... sorry but I cannot do anything about that):

C:\IDB-Git\IDB.All>msbuild IDB.All-Main.sln /t:TransformAll /p:Configuration=Debug /p:Platform="Any
CPU"
Microsoft (R) Build Engine, versión 12.0.31101.0
[Microsoft .NET Framework, versión 4.0.30319.34209]
Copyright (C) Microsoft Corporation. Todos los derechos reservados.

Los proyectos de esta solución se van a compilar de uno en uno. Para habilitar la compilación en par
alelo, agregue el modificador "/m".
Compilación iniciada a las 11/05/2015 04:37:44 p.m..
Proyecto "C:\IDB-Git\IDB.All\IDB.All-Main.sln" en el nodo 1 (TransformAll destinos).
ValidateSolutionConfiguration:
  Compilando la configuración de soluciones "Debug|Any CPU".
ValidateProjects:
  El proyecto"IDB.Presentation.Tests" no se seleccionó para la compilación en la configuración de s
  oluciones "Debug|Any CPU".
C:\IDB-Git\IDB.All\IDB.All-Main.sln.metaproj : error MSB4057: El destino "TransformAll" no existe e
n el proyecto. [C:\IDB-Git\IDB.All\IDB.All-Main.sln]
Compilación del proyecto terminada "C:\IDB-Git\IDB.All\IDB.All-Main.sln" (TransformAll destinos) --
 ERROR.


ERROR al compilar.

"C:\IDB-Git\IDB.All\IDB.All-Main.sln" (TransformAll destino) (1) ->
  C:\IDB-Git\IDB.All\IDB.All-Main.sln.metaproj : error MSB4057: El destino "TransformAll" no existe
 en el proyecto. [C:\IDB-Git\IDB.All\IDB.All-Main.sln]

    0 Advertencia(s)
    1 Errores

Tiempo transcurrido 00:00:00.15

回答1:

You do not have the Microsoft.TextTemplating.targets imported into your project file. This targets file provides the TransformAll target. Without this import this target does not exist and so MSBuild will error if you try to invoke this target.

If you refer to the documentation which is included in the target file at C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TextTemplating\Microsoft.TextTemplating.targets (Visual Studio 2013 path) it details how to include this target in your project.

Using this targets file


To use this targets file:

1) Import this targets file into your project by adding the appropriate <Import ...> e.g. <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TextTemplating\Microsoft.TextTemplating.targets" />

This import statement must be included after the standard VB/C# targets import, as it appends itself to the $(BuildDependsOn) property.