Entitas
Entitas copied to clipboard
How to setup Entitas in pure C# project?
Hi,
I have some questions about setting up Entitas in pure C# project.
- My component was not generated by Jenny.
- New project and add references to Entitas.dll and Entitas.CodeGeneration.Attributes.dll
- Extract Jenny.zip to project folder.
- Run
jenny new Entitas.properties
thenjenny auto-import -s
and choose all roslyn. - Fix
DesperateDevs.CodeGeneration.Plugins.ProjectPath
to beMyProj.csproj
- Add PositionComponent : IComponent file to /EntitasPure folder.
[Game]
public sealed class PositionComponent : IComponent
{
public float x;
public float y;
}
- Run
jenny server
- 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
- What's the point of Jenny server. Why don't just use jenny generate instead of the server?
Thanks :)
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.
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
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
@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?
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.
- Correct project name for sure.
- My component inherited Entitas.IComponent.
- I'm not in Unity but I've tried both .netstandard2.0 and .netframework4.7.
- 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.
@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.
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.
@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
I will dump a few images here, so I can reference them in the wiki




What's the .NET version of the project?
netstandard2.0
@kkohno
Jenny have bug with pure C# projects
Not quite sure what you mean. You can specify any folder.
@benzsuankularb As described in the wiki https://github.com/sschmid/Entitas-CSharp/wiki/Entitas-pure-C%23
here's a working project https://github.com/sschmid/EntitasPure
@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
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
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'
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
Seems to be an issue with the netcore csproj, works with .NET csproj
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
If components use custom datatypes as fields, those obviously have to be in that project too.
Thanks a lot. I forget about having reference from netcore to net4.x.
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.
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.
-
Create a .NET 4.7.1 or greater project
Generator
, extractJenny
folder intoGenerator
(do not use .Net Core project and set<TargetFramework>NET471</TargetFramework>
, that won't work) -
Include your folder like this:
<Compile Include="..\PureCSharpProject\Components\**\*.cs" />
<Compile Include="..\PureCSharpProject\Generated\**\*.cs" />
-
following Jenny configuration in Entitas Pure C#
-
set output directory, disable update csproj
Remove
DesperateDevs.CodeGeneration.Plugins.UpdateCSProjPostProcessor
Set
DesperateDevs.CodeGeneration.Plugins.ProjectPath = Generator.csproj
DesperateDevs.CodeGeneration.Plugins.TargetDirectory = ..\PureCSharpProject
- execute Jenny in
Generator
directory, likeE:\MyGame\src\Generator> Jenny\Jenny.exe gen
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:
Also see announcement: Jenny is now open-source https://github.com/sschmid/Entitas/discussions/1008