2

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
Luis
  • 2,833
  • 3
  • 27
  • 41

1 Answers1

3

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.

Michael Baker
  • 3,338
  • 26
  • 29
  • Thanks, now the target is found (after Including the EF templates), but now I'm getting a null when transforming. I'm not sure whether I should close this issue (since the initial problem is now solved) and open a new one with the new error or continue with this one. The error is: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): err or : Running transformation: System.NullReferenceException: Object reference not set to an instance of an object.\r [C:\IDB-Git\IDB.Middleware\IDB.MW.Domain\IDB.MW.Domain.csproj] – Luis May 13 '15 at 15:25
  • The StackOverflow way is question/answer. If your original question is answered then you should mark the one answer of that you feel best answers your question as the resolution. If you have another problem or question then you should ask that separately. Questions should ideally show that you have least tried to solve the problem yourself – explain why and how you are doing something so others have a better chance at getting into your headspace. – Michael Baker May 13 '15 at 20:36