T4 assembly directive with relative path in website design?

I have a website project in Visual Studio, and I'm trying to reference some assemblies from the bin directory on the site.

So far, the path with the roots has been the only one:

<#@ Assembly Name="C:\Code\Web Solution\Website\bin\My.dll" /> 

Other people mentioned using msbuild variables, but this does not work for me:

 <#@ Assembly Name="$(SolutionDir)Website\bin\My.dll" /> 

and I'm sure relative paths just don't work (my tt file is in a subfolder in App_Code):

 <#@ Assembly Name="..\..\bin\My.dll" /> 

Without using the root path, is there a way to make this work in the context of a website project?

+7
c # visual-studio-2010 t4
source share
4 answers

Assembly references in T4 templates require GAC or absolute paths.

However, you can use relative paths along a known path:

eg:

 $(SolutionDir)\..\..\packages\Pluralizer.0.3.0.1\lib\net40\Pluralize.dll 
+5
source share

does dll exist when starting T4?

I am creating MvcApplication1 with Application MVC 4 pattern.

create the App_Code directory and create tt.

<# @assembly name = "$ (ProjectDir) \ bin \ MvcApplication1.dll" #>

build a project and run it successfully for conversion

but you won’t be able to clear the assembly and run its results.

because clean removes the assembly dll assembly, the dll does not exist at the specified path.

+1
source share

I think you can find it using envDTE ( Example here to find the project in the bin directory.

0
source share

Try using slashes instead of backslashes when defining relative paths:

 <#@ Assembly Name="../../bin/My.dll" /> 
0
source share

All Articles