我想使用 MSBuild 转换我的 T4 模板,所以我找到了 this link 。但运行时:
msbuild solution.sln /t:TransformAll
我收到以下错误“项目中不存在目标“TransformAll””。
如果我尝试编译单个项目,也会发生同样的情况。无论我打开 VS 工具控制台还是常规控制台并获取 MSBuild 路径。
我错过了什么?
以下是我得到的输出(我担心它是西类牙语......抱歉,但我对此无能为力):
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
最佳答案
您没有将 Microsoft.TextTemplated.targets 导入到您的项目文件中。此目标文件提供 TransformAll 目标。如果没有此导入,则此目标不存在,因此如果您尝试调用此目标,MSBuild 将出错。
如果您引用位于 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TextTemplated\Microsoft.TextTemplated.targets(Visual Studio 2013 路径)的目标文件中包含的文档,则它详细说明如何将此目标包含在您的项目中。
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.
关于visual-studio-2013 - 项目 T4 转换 MSBuild 中不存在目标 "TransformAll",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30176352/