atifaziz / t5

T5 is T4 (Text Template Transformation Toolkit) for .NET Core
MIT License
79 stars 17 forks source link

Having trouble with syntax #15

Closed Prinsn closed 5 years ago

Prinsn commented 5 years ago

I'm currently trying to execute code in the template and having all sorts of trouble

dotnet tt CodeGen\test.ttx -o ClientApp\src\testing\httpMock\test.tt -r Web.dll -P=bin\Debug\netcoreapp2.2 -P=bin\Release\netcoreapp2.2 -u=Web -u=Web.CodeGen

Is giving me dotnet : No input file specified. where as I've gotten it to output with fewer arguments.

<#@ assembly name="Web" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="Web.CodeGen" #>

<#@ output extension=".tt" #>
<#

var darkHost = BlackMagic.DarkRitual();
var tome = new BlackMagic(darkHost.Services.CreateScope().ServiceProvider);
foreach(var varTuple in tome.AllVarTuples)
{ #>
   export const <#= varTuple.Name#> = <#= varTuple.Val#>;
<# } #>

Executing just dotnet tt on the file is giving

dotnet : (0,0): ERROR The type or namespace name 'Web' could not be found (are you missing a using directive or an assembly reference?)
At line:1 char:1
+ dotnet tt CodeGen\test.ttx -o ClientApp\src\testing\httpMock\test.tt
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: ((0,0): ERROR Th...bly reference?):String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

CodeGen\test.ttx(10,15): ERROR The name 'BlackMagic' does not exist in the current context
CodeGen\test.ttx(11,15): ERROR The type or namespace name 'BlackMagic' could not be found (are you missing a using directive or an assembly reference?)

I'm not sure how to resolve these problems given the help file, as offering too many, or certain, parameters seems to just arbitrarily prevent using it at all?

Prinsn commented 5 years ago

I cloned the repo and just set the args and it no longer complains about the lack of input file, but does give other error messages.

Inlined args of above

args = new[]{
    @"root\proj\Web\CodeGen\test.ttx",
    @"-o root\proj\Web\ClientApp\src\testing\httpMock\test.tt",
    @"-r Web.dll",
    @"-P=root\proj\Web\bin\Debug\netcoreapp2.2",
    @"-P=root\proj\Web\bin\Release\netcoreapp2.2",
    @"-u=Web",
    @"-u=CodeGen",
};

Output

(0,0): ERROR The type or namespace name 'Web' could not be found(are you missing a using directive or an assembly reference?)
(0,0): ERROR The type or namespace name 'Web' could not be found(are you missing a using directive or an assembly reference?)
~root\proj\Web\CodeGen\test.ttx(10,15): ERROR The name 'BlackMagic' does not exist in the current context
~root\proj\Web\CodeGen\test.ttx(11,15): ERROR The type or namespace name 'BlackMagic' could not be found(are you missing a using directive or an assembly reference?)
atifaziz commented 5 years ago

Can you try with dotnet-t4-project-tool? Do you get the same results.

T5 was created as a stopgap measure when Mono.TextTemplating didn't support .NET Core. Now that it does, I have no motivation/desire/itch for maintaining a separate fork. I would encourage you to use Mono.TextTemplating (actively maintained by @mhutch) and report the issue there if it still exists.

Prinsn commented 5 years ago

Fair.

I'll look into it.

I tried the just dotnet-t4 nuget and it rejected install, but I'll look for that and give it another go.

Thanks

On Fri, Aug 2, 2019, 5:49 AM Atif Aziz notifications@github.com wrote:

Can you try with dotnet-t4-project-tool https://www.nuget.org/packages/dotnet-t4-project-tool/? Do you get the same results.

T5 was created as a stopgap measure https://github.com/mono/t4/issues/8#issuecomment-363590843 when Mono.TextTemplating https://github.com/mono/t4 didn't support .NET Core. Now that it does, I have no motivation/desire/itch for maintaining a separate fork. I would encourage you to use Mono.TextTemplating (actively maintained https://github.com/mono/t4/issues/19 by @mhutch https://github.com/mhutch) and report the issue there if it still exists.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/atifaziz/t5/issues/15?email_source=notifications&email_token=AAYR7G3HLEDTISQOBADINYLQCP7MPA5CNFSM4IITHJIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3NIWZQ#issuecomment-517639014, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYR7G4N3C3KDEAI67ERNHTQCP7MPANCNFSM4IITHJIA .

mhutch commented 5 years ago

@Prinsn the dotnet-t4 package is a global tool (dotnet install -g dotnet-t4). For installing the tool into the project as a DotNetCliToolReference, use dotnet-t4-project-tool. Please note that dotnet-t4 currently targets .NET Core 2.1 and dotnet-t4-project-tool targets .NET Core 2.0, so you may have problems referencing assemblies that target 2.2.

(The need to have two different packages should go away soon, with .NET Core 3.0 local tools superseding DotNetCliToolReference)

Konard commented 5 years ago

@Prinsn did you see my answer https://github.com/mono/t4/issues/57#issuecomment-526858718, does it help with your case?

Prinsn commented 5 years ago

I understand what you were explaining, but the attempts to solve the problem with some form of t4 were abandoned for lack of progress

On Sat, Aug 31, 2019, 4:37 PM Konstantin Dyachenko notifications@github.com wrote:

@Prinsn https://github.com/Prinsn did you see my answer mono/t4#57 (comment) https://github.com/mono/t4/issues/57#issuecomment-526858718 does it help with your case?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/atifaziz/t5/issues/15?email_source=notifications&email_token=AAYR7G4FSKJQTNHGADACQRLQHLJBJA5CNFSM4IITHJIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5TUZQI#issuecomment-526863553, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYR7GZ2XBQ7RBDVRXHK7WDQHLJBJANCNFSM4IITHJIA .

atifaziz commented 5 years ago

but the attempts to solve the problem with some form of t4 were abandoned for lack of progress

Closing this on basis of the above and that Mono.TextTemplating is where this discussion should be happening anyway. Thanks all!