Reputation: 10974
I copied TextTransform.exe
from PC with VS 2015 Update 3 installed from location C:\Program Files (x86)\Common Files\Microsoft Shared\TextTemplating\14.0\TextTransform.exe
to PC without VS 2015 installed.
TextTransform.exe
is called as a part of build scripts.
When I run it I get following error:
Error: Exception has been thrown by the target of an invocation.
I read the article Code Generation in a Build Process.
I tried to copy all dll-s described in section "Configure your machines".
But I didn't found the folder $(ProgramFiles)\MSBuild\Microsoft\VisualStudio\v*.0\TextTemplating
on my PC with VS 2015 installed.
I copied files in other two folders described in the article to the folder which contains TextTransform.exe
on my PC without VS 2015 installed.
After running TextTransform.exe
the error still occurs.
How this error should be fixed?
How can I get TextTransform.exe
run?
UPDATE
I call TextTransform.exe
from MSBuild script. So if there are any approaches which can be implemented in MSBuild which performs text transformation functionality it would be acceptable for me, although requires to update build scripts.
I suppose such solution may exists because there are examples when MSBuild performs transformation without direct call of TextTransform.exe
, e.g. article mentioned above.
Upvotes: 7
Views: 2573
Reputation: 21999
There is a new official tool TextTransformCore.exe
(all arguments are the same as TextTransform.exe
), which is much easier to copy (all required files are there) and use (just copy required files and run):
{VS_INSTALL_PATH}\Common7\IDE\
TextTransformCore.dll
TextTransformCoreResolver.dll
TextTransformCore.exe
TextTransformCore.runtimeconfig.json
"SharedAssemblyPaths"
, its value contains all required folders"SharedAssemblyPaths": "TextTransform;PublicAssemblies;PrivateAssemblies;PrivateAssemblies\\Newtonsoft.Json.13.0.3.0;CommonExtensions\\Microsoft\\VBCSharp\\LanguageServices",
TextTransform
PublicAssemblies
PublicAssemblies
PrivateAssembliesPrivateAssemblies\\Newtonsoft.Json.13.0.3.0
CommonExtensions\\Microsoft\\VBCSharp\\LanguageServices
Upvotes: 0
Reputation: 98766
Took a while to unravel, but I have a working TextTransform.exe
! Here are the steps I found necessary (note: only tested with VS2015 and .NET 4.6.1):
First, on the build machine, copy all of the following files into C:\Program Files (x86)\Common Files\microsoft shared\TextTemplating\14.0
(or wherever you want the tool to end up):
C:\Program Files (x86)\Common Files\microsoft shared\TextTemplating\14.0\TextTransform.exe
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.VisualStudio.TextTemplating.14.0\v4.0_14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.TextTemplating.14.0.dll
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.TextTemplating.Interfaces.11.0.dll
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.TextTemplating.Interfaces.14.0.dll
C:\Program Files (x86)\MsBuild\14.0\Bin\Microsoft.CodeAnalysis.dll
C:\Program Files (x86)\MsBuild\14.0\Bin\Microsoft.CodeAnalysis.CSharp.dll
C:\Program Files (x86)\MsBuild\14.0\Bin\Microsoft.CodeAnalysis.VisualBasic.dll
C:\Program Files (x86)\MsBuild\14.0\Bin\System.Reflection.Metadata.dll
If your T4 templates contain C#/VB code, the Microsoft.VisualStudio.TextTemplating.Interfaces.10.0
and Microsoft.VisualStudio.TextTemplating.Interfaces.11.0
assemblies will be resolved from a dynamically-created app-domain, and will not be found next to TextTransform.exe
. They must be registered in the GAC instead.
From an Administrator command prompt, execute:
gacutil -i Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll
gacutil -i Microsoft.VisualStudio.TextTemplating.Interfaces.11.0.dll
Note: gacutil
is typically found in C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools
.
Create a TextTransform.exe.config
file next to TextTransform.exe
with binding redirects (may or may not be necessary depending on your .NET version):
<?xml version ="1.0"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="1.1.37.0" newVersion="1.1.36.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
When TextTransform.exe
first starts, it checks for a folder at %VS140COMNTOOLS%\..\IDE\PrivateAssemblies
and throws an exception if it does not exist.
So, either create a %VS140COMNTOOLS%
environment variable that points to a path accordingly, or create an empty ..\IDE\PrivateAssemblies
relative to the
working directory where TextTransform.exe
will be called from.
Upvotes: 3