#Hey, Generating bindings is broken in my
1 messages ยท Page 1 of 1 (latest)
Just saw the signature sorry
Hey, thanks for the response ๐
Yea it is the same just without ILogger
I am fixing it manually in the meantime ๐
but it happends every time I generate bindings, also - from the moment it started to happen I cant push my module with the deploy window - it says its above 10mb
but the weird thing is I can push it manually through CLI (the ccm file size is not really 10mb)
Something is wrong with the Cloud Code Module Reference File in the Unity Project maybe?
The module works perfectly fine.
this part looks like a bug on our side
Is this bug related to the module not deploying correctly?
Right now I have to publish-zip-copy-cli with every change
I believe those two issues are not related
I want to work on a repro on the first issue, for that I'd like to see the dependency injection setup you have
for from ideal indeed
Sure, just a clerification regarding sharing my code base, who can view this thread? besides the three of us?
Let me get back to you on this
As far as I can tell, its everyone ๐ I can see other threads here
I will censor my stuff manually
public class ModuleConfig : ICloudCodeSetup
{
public void Setup(ICloudCodeConfig config)
{
config.Dependencies.AddSingleton(GameApiClient.Create());
config.Dependencies.AddSingleton<IPushClient>(PushClient.Create());
config.Dependencies.AddSingleton<IAccountService, AccountService>();
config.Dependencies.AddSingleton<IRewardsService, RewardsService>();
config.Dependencies.AddSingleton<IInventoryService, InventoryService>();
config.Dependencies.AddSingleton<IStoreService, StoreService>();
}
}
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Server.Accounts;
using Unity.Services.CloudCode.Core;
namespace Server.Games;
public class GameController
{
[CloudCodeFunction("ClearStageRpc")]
public async Task ClearStageRpc(IExecutionContext ctx, string playerId, ILogger<GameController> logger, IAccountService accountService)
{
logger.LogInformation("Player '${playerId}' clear stage Rpc Recieved.", playerId);
await accountService.HandleClearStageAsync(ctx, playerId);
}
}
I guess this is what you need.
Thanks! at some point if you are uncomfortable sharing code, we can use DMs
Sure, thanks
OK I could finally have a look at your snippet.
Could you try and follow the pattern for logging as shown here: https://docs.unity.com/ugs/en-us/manual/cloud-code/manual/logging/tutorials/emit-logs
And get back to me?
In the example I provide, the logger is passed to the GameController constructor and saved as a member, instead of being passed as a variable in the cloud code function.
It does work
But The docs says its OK to DI through the methods
Why with other Unity classes or my own classes the DI works correctly in the method param?
well they are registered in a different way, without you having to explicitly register the singleton in the setup function, I guess this special case isn't handled well in our code analysis, so it's a bug on our side. I'm filing it, we will fix it asap.
In the mean time, please avoid using the ILogger as injected dep in the method.
Thanks for the update!
Is there a recommended DI method between the two? (method or constructor)
For the rest of the dependencies ofc
And more importantly - how can I fix not being able to upload the module no more?
Hey Arg4z, I would go with the constructor, simply because in case the logger is not a singleton it will avoid the reinstantiation at every function call.
Do you happen to have a link to the doc we offer where we advise to do DI directly in the method? Couldn't find it ๐ฅฒ
https://docs.unity.com/ugs/en-us/manual/cloud-code/manual/modules/how-to-guides/initialize-modules/dependency-injection
I wouldn't say advise so much as - "there is an option of"
maybe in this part - Scoped: Scoped dependencies are created once per request. Whether you use it in the constructor or the method itself doesn't matter since they both link to the same object.
Concerning this, for now, use the CLI workaround, we filed a bug and will fix it soon
Hi @vague whale,
I'm looking into why the CLI and Editor would generate different sized .ccm files
I cant push my module with the deploy window - it says its above 10mb
I have a few questions for you:
- What version of the CLI are you using?
- What version of the Cloud Code package are you using in your project?
- Is it possible that your Cloud Code C# project legitimately contains a lot of code/dependencies?
Hi ๐
-
CLI Version 1.4.0
-
Cloud Code Version 2.6.2, Deployment Package Version 1.3.0
-
No, the project is quite new and small but
Something Interesting I can say regarding the issue:
I had two projects in the solution - main one, and a DTO library.
It worked fine.
When I tried adding a test project (third one) it started to happen.
I even tried removing this project or start over completely (new solution, same name) and it does not work anymore.
CLI works fine.
CLI final size - 2.14 MB
So using deploy with the CLI you get a .ccm file that's 2.14 MB?
Could you let me know with the Deployment Window how much the .ccm file ends up being?
You can run this to get the path where the .ccm file lives easily: Debug.Log($"{Path.GetTempPath()}/{your_solution_name}");
Note that you'll need to Deploy from the Deployment Window beforehand
So using deploy with the CLI you get a .ccm file that's 2.14 MB`
Yes
I found it, It is 12.5 MB in size.
(the deployment tool generated one)
Hi @vague whale,
To help me reproduce the bug, would you be willing to share your Cloud Code C# solution in DMs or over to yoan.bernatchez@unity3d.com?
It would be used solely to reproduce the bug, and discarded right after
There's another person also reporting a similar issue, so no pressure if you don't want to share it (just testing my luck) ๐
For debugging purposes I am OK with sharing it, will DM you soon.
Hi @vague whale,
I have a temporary solution that might work for you (for the 10mb+ problem) before we come up with an official guidance
Can you try disabling your Tests project in your 'Release' build configuration (in your IDE) and let me know if that helps?
I have my own release build (I am using rider)
Should I create a new one named Release?
I did some research and the way that the deploy works at the moment is that it uses the 'Release' configuration by default
This means if you have two configurations initially 'Debug' and 'Production', you'll have to add a third one 'Release' with your Test project deactivated
Let me know if that helps
https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/8.0/dotnet-publish-config
Although there's probably a solution configuration file somewhere where a specific configuration can be set to be used by default for publishing - looking into it
I just posted the official guidance here for now: https://forum.unity.com/threads/cloud-code-deployment-error.1596180/#post-9847716
I encourage you to take a look at it; there is currently a bug described in the comment that you'll need to be careful of
We're working on a fix ASAP ๐
Hi,
I used Clode Code and deployed using Unity and everything worked flawlessly. But I added a project with unit tests to the Cloude Code solution and...