8

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

So far, the rooted path is the only one that works:

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

Other people mentioned using msbuild variables, but this doesn't work for me:

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

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

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

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

John B
  • 20,062
  • 35
  • 120
  • 170

4 Answers4

7

GAC or absolute paths are required for assembly references in T4 Templates.

However you can use relative paths from a known path:

eg:

$(SolutionDir)\..\..\packages\Pluralizer.0.3.0.1\lib\net40\Pluralize.dll
Mark Redman
  • 24,079
  • 20
  • 92
  • 147
1

is dll exist on running T4?

I create MvcApplication1 with MVC 4 Application template.

create App_Code directory and create tt.

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

build the project and run it succeed to trasnform

but clean the build and run it results fail.

because, clean removes build output dll ,dll not existing on specified path.

kazuk
  • 114
  • 4
  • Well this is a website project... so this particular DLL is always in the bin, and never gets cleaned. – John B Jul 25 '13 at 15:26
  • To be more specific, the project is a "website project", so I think that is why those macros/variables for the project/solution directory doesn't work. – John B Jul 25 '13 at 15:38
  • oh sorry, I testing with website project now. but I can not found the dll on bin. repro steps Create website project, add Bin directory and App_Code Directory, create Class1.cs on App_Code, – kazuk Jul 25 '13 at 15:39
  • not work. I write a project property enumeration https://gist.github.com/kazuk/6085409 ,results Website project don't have ProjectDir property, and founds FullPath property, but $(FullPath) doesn't work on me. It looks for me, macro expanding is not work on Website project. – kazuk Jul 26 '13 at 02:03
0

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

Community
  • 1
  • 1
Henrik Gering
  • 1,769
  • 16
  • 29
0

Try using slashes instead of backslashes when defining relative paths:

<#@ Assembly Name="../../bin/My.dll" />
daryal
  • 14,643
  • 4
  • 38
  • 54
  • @JohnBubriski it is strange since we are using the relative paths with backslashes and it is working. Maybe, inside an Assembly node it is not working this way. – daryal Jul 26 '13 at 06:29
  • Are you using a website project, or a web application project? – John B Jul 26 '13 at 13:41