0

I have a project A in Visual Studio where I need some files from project B (to keep a single point of definition). I use these files in project A for Chutzpah to include the dependencies for the tests, for example jQuery. This works by adding jQuery AS LINK from project B to project A.

Now I am trying to build a t4 template to generate the HTML file including some DOM elements, a script and a test script. In the t4 template you can read a file to include:

<#
  string root = Host.ResolvePath(string.Empty);
  string relativePath = @"..\..\..\..\Scripts\Script files\jquery-1.5.1.min.js";
  string jquery = File.ReadAllText(Path.Combine(root, relativePath));
#>

<script src="<#= jquery#>"></script>

This is the path to the folder where jQuery is added as link. Obviously this does not work, because the files aren't really there, only as link in the Visual Studio project.

Is there a way to read the files anyway from the t4 template?

devqon
  • 13,818
  • 2
  • 30
  • 45
  • Not sure about the t4 issue but for Chutzpah, why do you need to use the links? – Matthew Manela May 08 '14 at 14:29
  • If I understand you correctly then you can parse the VS project (it's an xml file) and extract the links from there. – Just another metaprogrammer May 08 '14 at 18:55
  • @MatthewManela because we maintain a single point of definition in our solution. In our project where the js is placed to be tested ánd the tests are written we need to use the dependencies of the other project. If referencing directly it would be something like "../../../../../ProjectA/folder/folder/folder/scripts/jquery" – devqon May 09 '14 at 07:39
  • You can use a Chutzpah.json file to manage those references so you don't need the link – Matthew Manela May 09 '14 at 14:42

0 Answers0