Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to setup Entitas in pure C# project? #806

Closed
benzsuankularb opened this issue Oct 6, 2018 · 25 comments
Closed

How to setup Entitas in pure C# project? #806

benzsuankularb opened this issue Oct 6, 2018 · 25 comments

Comments

@benzsuankularb
Copy link

benzsuankularb commented Oct 6, 2018

Hi,

I have some questions about setting up Entitas in pure C# project.


  1. My component was not generated by Jenny.
    1. New project and add references to Entitas.dll and Entitas.CodeGeneration.Attributes.dll
    2. Extract Jenny.zip to project folder.
    3. Run jenny new Entitas.properties then jenny auto-import -s and choose all roslyn.
    4. Fix DesperateDevs.CodeGeneration.Plugins.ProjectPath to be MyProj.csproj
    5. Add PositionComponent : IComponent file to /EntitasPure folder.
[Game]
public sealed class PositionComponent : IComponent
{
   public float x;
   public float y;
}
  1. Run jenny server
  2. Run jenny client gen

Now everything are generated but nothing about Position component generated for me.
I'm not sure what I'm missed?
Maybe we should add this scenario to the Wiki.

Entitas 1.8.2 from the AssetStore


  1. What's the point of Jenny server. Why don't just use jenny generate instead of the server?

Thanks :)

@benzsuankularb benzsuankularb changed the title How to setup Jenny code generator in pure C# project? How to setup Entitas in pure C# project? Oct 6, 2018
@benzsuankularb
Copy link
Author

benzsuankularb commented Oct 6, 2018

My Entitas.properties

Jenny.Ignore.Keys = 
Jenny.SearchPaths = Jenny/Jenny/Plugins/DesperateDevs, \
                    Jenny/Jenny/Plugins/Entitas, \
                    Jenny/Jenny/Plugins/Entitas.Roslyn

Jenny.Plugins = DesperateDevs.CodeGeneration.Plugins, \
                DesperateDevs.CodeGeneration.Unity.Plugins, \
                Entitas.CodeGeneration.Plugins, \
                Entitas.Roslyn.CodeGeneration.Plugins, \
                Entitas.VisualDebugging.CodeGeneration.Plugins

Jenny.PreProcessors = DesperateDevs.CodeGeneration.Plugins.ValidateProjectPathPreProcessor, \
                      DesperateDevs.CodeGeneration.Plugins.TargetFrameworkProfilePreProcessor

Jenny.DataProviders = Entitas.CodeGeneration.Plugins.ContextDataProvider, \
                      Entitas.Roslyn.CodeGeneration.Plugins.CleanupDataProvider, \
                      Entitas.Roslyn.CodeGeneration.Plugins.ComponentDataProvider, \
                      Entitas.Roslyn.CodeGeneration.Plugins.EntityIndexDataProvider

Jenny.CodeGenerators = Entitas.CodeGeneration.Plugins.ComponentContextApiGenerator, \
                       Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, \
                       Entitas.CodeGeneration.Plugins.ComponentEntityApiInterfaceGenerator, \
                       Entitas.CodeGeneration.Plugins.ComponentGenerator, \
                       Entitas.CodeGeneration.Plugins.ComponentLookupGenerator, \
                       Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator, \
                       Entitas.CodeGeneration.Plugins.ContextAttributeGenerator, \
                       Entitas.CodeGeneration.Plugins.ContextGenerator, \
                       Entitas.CodeGeneration.Plugins.ContextMatcherGenerator, \
                       Entitas.CodeGeneration.Plugins.ContextsGenerator, \
                       Entitas.CodeGeneration.Plugins.EntityGenerator, \
                       Entitas.CodeGeneration.Plugins.EntityIndexGenerator, \
                       Entitas.CodeGeneration.Plugins.EventEntityApiGenerator, \
                       Entitas.CodeGeneration.Plugins.EventListenerComponentGenerator, \
                       Entitas.CodeGeneration.Plugins.EventListenertInterfaceGenerator, \
                       Entitas.CodeGeneration.Plugins.EventSystemGenerator, \
                       Entitas.CodeGeneration.Plugins.EventSystemsGenerator, \
                       Entitas.Roslyn.CodeGeneration.Plugins.CleanupSystemGenerator, \
                       Entitas.Roslyn.CodeGeneration.Plugins.CleanupSystemsGenerator, \
                       Entitas.VisualDebugging.CodeGeneration.Plugins.ContextObserverGenerator, \
                       Entitas.VisualDebugging.CodeGeneration.Plugins.FeatureClassGenerator

Jenny.PostProcessors = DesperateDevs.CodeGeneration.Plugins.AddFileHeaderPostProcessor, \
                       DesperateDevs.CodeGeneration.Plugins.CleanTargetDirectoryPostProcessor, \
                       DesperateDevs.CodeGeneration.Plugins.MergeFilesPostProcessor, \
                       DesperateDevs.CodeGeneration.Plugins.NewLinePostProcessor, \
                       DesperateDevs.CodeGeneration.Plugins.UpdateCSProjPostProcessor, \
                       DesperateDevs.CodeGeneration.Plugins.WriteToDiskPostProcessor, \
                       DesperateDevs.CodeGeneration.Plugins.ConsoleWriteLinePostProcessor

Jenny.Server.Port = 3333
Jenny.Client.Host = localhost
DesperateDevs.CodeGeneration.Plugins.ProjectPath = MyProj.csproj
Entitas.CodeGeneration.Plugins.Contexts = Game, \
                                          Input

Entitas.CodeGeneration.Plugins.IgnoreNamespaces = false
DesperateDevs.CodeGeneration.Plugins.TargetDirectory = ./

jenny doctor said happy coding.

@kkohno
Copy link

kkohno commented Oct 6, 2018

I will add, that Jenny have bug with pure C# projects: It is only works if your generated output folder is in Assets folder root, even if you change this paths in *.properties file

@kkohno
Copy link

kkohno commented Oct 6, 2018

change TargetDirectory sring in your .properties file as follows, and it will works:
DesperateDevs.CodeGeneration.Plugins.TargetDirectory = Assets

also you can make following bat file to generate without servers and unity:
pushd %~dp0
.\Jenny\Jenny.exe gen
popd

@benzsuankularb
Copy link
Author

benzsuankularb commented Oct 6, 2018

@kkohno

I will add, that Jenny have bug with pure C# projects: It is only works if your generated output folder is in Assets folder root, even if you change this paths in *.properties file

Nah, Still not work.
But maybe it's a bug like you said.

also you can make following bat file to generate without servers and unity:
pushd %~dp0
.\Jenny\Jenny.exe gen
popd

Yeah, But what's the point of server then?

@benzsuankularb
Copy link
Author

benzsuankularb commented Oct 6, 2018

issues 706 No help with this.


Similar issues:

issues 803
I think the same issue here. But that's in Unity. From @sschmid mentioned there.

  1. Correct project name for sure.
  2. My component inherited Entitas.IComponent.
  3. I'm not in Unity but I've tried both .netstandard2.0 and .netframework4.7.
  4. If I remove <TargetFramework>netstandard2.0</TargetFramework> project will unable to restore.

issues 759
Maybe look like the same issue but I don't know why he can get it worked on .netframework.

issue 798
issue 798
No info. But maybe the same problem.

Pretty severe somehow I think.

Repository owner deleted a comment from benzsuankularb Oct 6, 2018
@benzsuankularb
Copy link
Author

benzsuankularb commented Oct 7, 2018

@sschmid I've removed the repo. Apologize for that, I didn't mean to do it.

Here's the new sample repo.
Please investigate this, I can't continue working on the project.

@TheHacky
Copy link

TheHacky commented Oct 7, 2018

What's the point of Jenny server. Why don't just use jenny generate instead of the server?

The server is for caching purpose. So running the server will result in faster generation process with the second run. You can also use Jenny alone, but then without caching and every run will take longer.

@sschmid
Copy link
Owner

sschmid commented Oct 9, 2018

@benzsuankularb I added a new wiki page with a step by step guide, how to set up a C# only project with Entitas

https://github.com/sschmid/Entitas-CSharp/wiki/Entitas-pure-C%23

I hope this helps

@sschmid
Copy link
Owner

sschmid commented Oct 9, 2018

I will dump a few images here, so I can reference them in the wiki

entitaspure-jenny

entitaspure-gen

entitaspure-done

entitaspure-folders

@sschmid
Copy link
Owner

sschmid commented Oct 9, 2018

What's the .NET version of the project?

@benzsuankularb
Copy link
Author

netstandard2.0

@sschmid
Copy link
Owner

sschmid commented Oct 9, 2018

@kkohno

Jenny have bug with pure C# projects

Not quite sure what you mean. You can specify any folder.

@sschmid
Copy link
Owner

sschmid commented Oct 13, 2018

@benzsuankularb
Copy link
Author

benzsuankularb commented Oct 13, 2018

@sschmid
.framework is OK but still not working with .netstandard and .netcore.

I think it's about <Compile Include="..."> not working on .netstandard.

I've updated 100% as you describe in the wiki.
https://github.com/benzsuankularb/EntitasIssue806

@sschmid
Copy link
Owner

sschmid commented Oct 13, 2018

Installed dotnet 2. First impression, csproj works differently. Source files are not listed but recognized. To fix compilation, I removed DesperateDevs.CodeGeneration.Plugins.UpdateCSProjPostProcessor to prevent <Compile Include="...">

Have to investigate further. My guess, since the project file is empty, no components are found

@sschmid
Copy link
Owner

sschmid commented Oct 13, 2018

Duplicate 'Compile' items were included. The .NET SDK includes 'Compile' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultCompileItems' property to 'false' if you want to explicitly include them in your project file. For more information, see https://aka.ms/sdkimplicititems

Try setting 'EnableDefaultCompileItems' property to 'false'

@sschmid
Copy link
Owner

sschmid commented Oct 13, 2018

I readded DesperateDevs.CodeGeneration.Plugins.UpdateCSProjPostProcessor and added

<EnableDefaultCompileItems Condition=" '$(EnableDefaultCompileItems)' == '' ">false</EnableDefaultCompileItems>

to the projects <PropertyGroup> and readded Program.cs and HealthComponent.cs
Code Generation and updating the project works now, but still no component generated

@sschmid
Copy link
Owner

sschmid commented Oct 13, 2018

Seems to be an issue with the netcore csproj, works with .NET csproj

@sschmid
Copy link
Owner

sschmid commented Oct 13, 2018

This works as a workaround for net core solutions:

Add a new .NET 4.x project for all your components within your solution with a standard jenny setup and reference this project in you net core project. All components and generated code will be in the .NET 4.x project, all your production code in the net core project

@sschmid
Copy link
Owner

sschmid commented Oct 13, 2018

If components use custom datatypes as fields, those obviously have to be in that project too.

@benzsuankularb
Copy link
Author

Thanks a lot. I forget about having reference from netcore to net4.x.

@Zonciu
Copy link

Zonciu commented Nov 17, 2018

Same issue, my project is <TargetFrameworks>netstandard2.0;netcoreapp2.1</TargetFrameworks>, it doesn't generate Component code.
Now I use mklink to link all code files to a Unity project to generate codes, that works fine.

@hegi25
Copy link

hegi25 commented Feb 18, 2019

Can also be done without linking with creating a dummy 4.7.1 csproj file with ItemGroup: <Compile Include="path/Components/**/*.cs" />. You can also disable generate csproj file in jenny settings. Much cleaner and more simple solution.

@Zonciu
Copy link

Zonciu commented Apr 19, 2019

  1. Create a .NET 4.7.1 or greater project Generator, extract Jenny folder into Generator (do not use .Net Core project and set <TargetFramework>NET471</TargetFramework>, that won't work)

  2. Include your folder like this:

<Compile Include="..\PureCSharpProject\Components\**\*.cs" />
<Compile Include="..\PureCSharpProject\Generated\**\*.cs" />
  1. following Jenny configuration in Entitas Pure C#

  2. set output directory, disable update csproj

Remove

DesperateDevs.CodeGeneration.Plugins.UpdateCSProjPostProcessor

Set

DesperateDevs.CodeGeneration.Plugins.ProjectPath = Generator.csproj
DesperateDevs.CodeGeneration.Plugins.TargetDirectory = ..\PureCSharpProject
  1. execute Jenny in Generator directory, like E:\MyGame\src\Generator> Jenny\Jenny.exe gen

@sschmid
Copy link
Owner

sschmid commented Sep 9, 2022

Here's a sample Entitas project as a dotnet console app using .NET 6.0 and .NET Standard 2.1, including a working Jenny setup:

Entitas-Standalone

Also see announcement: Jenny is now open-source
#1008

@sschmid sschmid closed this as completed Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

6 participants