curiosity-ai / h5

🚀 The next generation C# to JavaScript compiler
https://github.com/curiosity-ai/h5
Apache License 2.0
210 stars 30 forks source link

Building issues on multiple platforms #70

Closed ghost closed 1 year ago

ghost commented 1 year ago

I think current version of H5 is not usable much.

1) UpdateH5 option simply does not work as intended. If you have NET 7 installed it will update your installed h5 tools in any case. If you have only NET 6 then it cannot update and will not install new version. But enabling this option can reduce amount of error in the log.

2) It always puts a lot of different warnings which should not be displayed in case of normal building process:

For example: Warning MSB3073 The command "dotnet tool run h5 check-if-online" exited with code 1

image

Exit code other than zero means that external program completed not successful.

@theolivenbaum Can you provide any feedback? We cannot hear anything from you.

theolivenbaum commented 1 year ago

@hardhub This is due to the update of h5 to target net70, which needs then the SDK installed on your computer. You can download the latest .NET SDK here: https://dotnet.microsoft.com/en-us/download And re-install the latest version of h5 with the command: dotnet tool update --global h5-compiler --version 0.0.34002

ghost commented 1 year ago

I wrote above about NET 7.

And I obviously tested it on .NET 7.

dotnet --version
7.0.100

You closed it too quick ))

theolivenbaum commented 1 year ago

Good point, missed that!

ghost commented 1 year ago

For build output you can see this comment: https://github.com/theolivenbaum/h5/issues/71#issuecomment-1324890564

>C:\Users\hardhub\.nuget\packages\h5.target\0.0.34005\Sdk\Sdk.targets(461,5): warning MSB3073: The command "h5 check-if-online" exited with code 9009.
1>Cannot find a tool in the manifest file that has a command named 'h5'.
1>C:\Users\hardhub\.nuget\packages\h5.target\0.0.34005\Sdk\Sdk.targets(470,5): warning MSB3073: The command "dotnet tool run h5 check-if-online" exited with code 1.

I was not able to look at Sdk targets to analyze anything because I just completed porting some Bridge frameworks projects and the project based on Bridge in the past. I wrote about frameworks in Gitter: https://gitter.im/curiosityai/h5#. But it seems nobody uses it actively.

theolivenbaum commented 1 year ago

Interesting, which version of VS do you have installed? If you want to chat directly you can join our app slack.

ghost commented 1 year ago

Interesting, which version of VS do you have installed?

I guess it does not matter, because it happens even under gitlab-runner (CentOS 7, .NET 7, Microsoft Official Repository)

 h5 check-if-online
/home/gitlab-runner/.nuget/packages/h5.target/0.0.34005/Sdk/Sdk.targets(461,5): warning MSB3073: The command "h5 check-if-online" exited with code 134.

Difference only in exit code for different platforms, for VS and Windows it is 1 and for Linux it is any none-zero as I see that.

theolivenbaum commented 1 year ago

The error code there is on purpose, as we need to start the compilation server - we do it this way because the compiler caches some of the state in across compilations for speed.

For CIs, we don't run the compiler as server, as you can see here.

The reason you always see the error code is that we run two checks, one for the globally installed compiler, and one for the locally installed one. We run this to make sure you're running the latest version of the compiler, because I didn't want to support the complexity added by the original Bridge CLI that let you mix multiple versions of the CLI / compiler / base library.

All that said, I'm sure this can be improved - either by adding some flags to disable this process, or something else. I'll leave this open to track the issue

ghost commented 1 year ago

Thank for good explanation.

As I see it we need to inform calling code about status of server:

try
{
    await remoteCompiler.Ping(_exitToken.Token);
    Logger.LogInformation("Found compilation server");
    return 0;
}
catch (Exception E)
{
    Logger.LogInformation("Compilation server not online");
    return 1;
}

It is a bit unclear for me what calls this tool. And why we need to tell some number outside - why we cannot just start it silently and always return 0.

Because on my screenshot above it looks like it returns 1 even if H5 is already started.
So I can track output in console of H5 server, I can observe how it builds a project, but warning check-if-online exited with code 1 continues to be added into Error List for each project which it starts to build. Maybe it raises exception if H5 is already started for another H5-based project in solution and it is the reason why it returns 1?

I guess I will need to analyze implementation details to be more specific.

ghost commented 1 year ago

And if I build using multiple threads via CLI (for example `msbuild /maxcpucount:8 instead of /maxcpucount:1) then I get warnings about h5-compiler:

The command "dotnet tool update --global h5-compiler" exited with code 1.
theolivenbaum commented 1 year ago

@hardhub I've changed the logic in the SDK target to ignore the exit code and instead use the exit code value, this should fix this warning (but you'll need to update the SDK target in your projects

theolivenbaum commented 1 year ago

Just remembered there's an auto-update of the target value in the compiler so as long as you update the compiler it should be fine!