❔ T4 Compiling transformation error
Hi,
I'm upgrading a solution to .net 7.0. One of the projects contains T4 transformation templates. Getting the following error even though the target framework is set to net7.0 for all projects contained within the solution.
Compiling transformation: The type 'List<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Collections, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
I have updated the tarhet sdk to net7.0 in all the projects, updated sdk version in the global.json files, deleted the vs, bin and obj directories, cleaned the solution, reopened solution, rebuilt solution, upgrade Visual Studio 2022 to the latest version but there is still an issue
when I try to add a reference to system.Collections an error is displayed saying that the dll is invalid or not supported
anyone got any ideas what's wrong?
Thanks
7 Replies
T4 runs on an isolated context with their own references. have you tried to reference it using
and then
?
Hi @cypherpotato I already had those lines of code in place. The error is triggered by this line when I execute this line of code:
<#
List<T4HelperV2.ObjectToUse> listOfObjectsToGenerate = new List<T4HelperV2.ObjectToUse>();
ObjectToUse is contained within a .cs class file. This class is referenced as follows:
<#@ assembly name="$(TargetDir)T4HelperV2.dll" #>
<#@ import namespace="T4HelperV2" #>
<#@ include file="$(ProjectDir)ModelMapper.cs" #>
This is the new error:
Running transformation: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.Hi @cypherpotato Managed to resolve it by leaving the project and the projects referenced on netstandard2.1. Was able to upgrade the other projects to dotnet 7.0
closed
$close
Use the /close command to mark a forum thread as answered
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.