TypeLITE with multiple projects
Asked Answered
M

1

6

I am using TypeLITE with various projects and a simple web site. I would like to use TypeLITE to generate TypeScript definitions from my C# classes, but I am not allowed to add the TypeLITE dll's to every project.

Let this be my project structure:

Solution
|
|
----- WebSite (with NuGet-Installation of TypeLITE)
|
|
----- FirstProject
|
|
----- SecondProject
|
|
----- ThirdProject

I installed TypeLITE via NuGet-Console and the C#-Classes are located in "FirstProject", "SecondProject" and "ThirdProject".

Problem: I have to use the NuGet-Installation for all other projects.

Is this possible?

Misdate answered 10/6, 2014 at 11:45 Comment(0)
M
7

If you want to use definitions of classes from the FirstProject in your WebSite, you can just add reference to the FirstProject to the TypeLite.tt file inside your WebSite

<#@ assembly name="$(TargetDir)FirstProject.dll" #>

and classes from the FirstProject will become available to the TypeLITE.

(if FirstProject.dll isn't located in the bin folder of your WebSite, you have to use appropriate directory instead of $(TargetDir))

Meave answered 10/6, 2014 at 16:12 Comment(3)
I tried this, but it doesn't work. As I understand this, I have to add the "[TsClass]" entry to every class where I would like to use with the TypeLITE Scripts. But the [TsClass]-entry is not valid without the reference of TypeLite.dllMisdate
The TsClass attribute is only required for auto-discovery of classes by the ForLoadedAsemblies method. Instead of using the ForLoadedAsemblies method, you can add classes manually to the model - TypeScript.Definitions().For<YourClass1>().For<YourClass2>()Meave
@LukasKabrt do you have any idea how to customise guid properties to be of type any in ts using typelite? It just creates an interface guid definition. WebEssentials create a property of type any but that's manual approach by right click context menu!Boak

© 2022 - 2024 — McMap. All rights reserved.