You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to refer a class declared in a separate assembly. Since my code generation happens as a pre-build event and the classes generated must be added to the build, I need to refer the assembly in the output folder where it is created as part of the build process.
will result in the following error being logged during build:
System.IO.FileLoadException: The given assembly name or codebase was invalid. (0x80131047)
2> at System.Reflection.AssemblyName.nInit()
2> at System.Reflection.AssemblyName..ctor(String assemblyName)
2> at Mono.TextTemplating.TemplateGenerator.ResolveAssemblyReference(String assemblyReference) in D:\a\t4\t4\Mono.TextTemplating\Mono.TextTemplating\TemplateGenerator.cs:line 221
2> at Mono.TextTemplating.TemplateGenerator.Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost.ResolveAssemblyReference(String assemblyReference) in D:\a\t4\t4\Mono.TextTemplating\Mono.TextTemplating\TemplateGenerator.cs:line 400
2> at Mono.TextTemplating.TemplatingEngine.ProcessReferences(ITextTemplatingEngineHost host, ParsedTemplate pt, TemplateSettings settings) in D:\a\t4\t4\Mono.TextTemplating\Mono.TextTemplating\TemplatingEngine.cs:line 301
2> at Mono.TextTemplating.TemplatingEngine.CompileTemplateInternal(ParsedTemplate pt, String content, ITextTemplatingEngineHost host, TemplateSettings settings) in D:\a\t4\t4\Mono.TextTemplating\Mono.TextTemplating\TemplatingEngine.cs:line 198
2> at Mono.TextTemplating.TemplatingEngine.CompileTemplate(ParsedTemplate pt, String content, ITextTemplatingEngineHost host, TemplateSettings settings) in D:\a\t4\t4\Mono.TextTemplating\Mono.TextTemplating\TemplatingEngine.cs:line 174
2> at Mono.TextTemplating.ToolTemplateGenerator.ProcessTemplate(ParsedTemplate pt, String inputFile, String inputContent, String& outputFile, TemplateSettings settings) in D:\a\t4\t4\dotnet-t4\ToolTemplateGenerator.cs:line 64
2> at Mono.TextTemplating.TextTransform.MainInternal(String[] args) in D:\a\t4\t4\dotnet-t4\TextTransform.cs:line 218
2> at Mono.TextTemplating.TextTransform.Main(String[] args) in D:\a\t4\t4\dotnet-t4\TextTransform.cs:line 42
If I refer the assembly by its fill path, the build process completes fine. That is not an option because my project is also built in an Azure DevOps pipeline where the output folder will obviously be different.
Is there any solution for this?
TIA,
Eddie
The text was updated successfully, but these errors were encountered:
You can use the -P command-line option to specify a directory to be searched when resolving assemblies.
AFAIK the $(OutDir) macro isn't a feature of the the T4 engine, it's a feature of the Visual Studio in-process T4 host, which parses resolved certain $() expressions to built-in values from the project system. You would have the same problem executing the templates with Visual Studio's TextTransform.exe CLI tool or MSBuild targets.
I'm open to proposals for solutions to this problem. Perhaps a CLI argument for passing in values to be used in directives using $(name), or allow directives to access session or host parameters.
Good afternoon! It would be great to add a CLI Argument to pass values to be used in directives using $(name), or allow directives to access session or host parameters.
<#@ assembly name="$(TargetDir)$(TargetFileName)" #>
ERROR: Could not find metadata file $(TargetDir)$(TargetFileName).dll"
I need to refer a class declared in a separate assembly. Since my code generation happens as a pre-build event and the classes generated must be added to the build, I need to refer the assembly in the output folder where it is created as part of the build process.
Adding the reference as such:
<#@ assembly name="$(OutDir)\MyOtherAssembly.dll" #>
will result in the following error being logged during build:
If I refer the assembly by its fill path, the build process completes fine. That is not an option because my project is also built in an Azure DevOps pipeline where the output folder will obviously be different.
Is there any solution for this?
TIA,
Eddie
The text was updated successfully, but these errors were encountered: