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

Referencing netstandard2.0 library projects. #29

Open
IceReaper opened this issue Oct 21, 2020 · 9 comments
Open

Referencing netstandard2.0 library projects. #29

IceReaper opened this issue Oct 21, 2020 · 9 comments

Comments

@IceReaper
Copy link

I am working on an opengl/webgl based ui rendering library. The project is setup as follows:

  • UniGui.Core <- NetStandard 2.0 library, standard sdk, contains an iGlContext interface with all the gl calls defined plus the ui system.
  • UniGui.Desktop <- NetStandard 2.0 library, standard sdk, OpenTK based implementation of the Core interfaces.
  • UniGui.Html5 <- NetStandard 2.0 library, H5 sdk, H5 webgl2 based implementation of the Core interfaces.

Using Bridge.net it was possible to reference one of the implementation projects, and compile the whole application into either an desktop or webgl powered application. Using H5 however, compiling the Html5 projects results in:

         [info] [10:36:24]  
         
              __ _  _  _  _ 
             |_ |_)|_)/ \|_)
             |__| \| \\_/| \
         
         
         [fail] [10:36:24]  
     1>H5 : error H5003: Could not find file '/home/andre/RiderProjects/Tetys/csharp/Tetys.Libs.UniGui.Core/bin/Debug/netstandard2.0/netstandard.dll'.
         [fail] [10:36:24]  
         Stack Trace:    at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
            at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
            at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
            at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
            at Mono.Cecil.ModuleDefinition.GetFileStream(String fileName, FileMode mode, FileAccess access, FileShare share)
            at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
            at H5.Translator.Translator.AddNestedReferences(List`1 referencesPathes, String refPath)
            at H5.Translator.Translator.AddNestedReferences(List`1 referencesPathes, String refPath)
            at H5.Translator.Translator.BuildAssembly(CancellationToken cancellationToken)
            at H5.Translator.Translator.Translate(CancellationToken cancellationToken)
            at H5.Translator.TranslatorProcessor.Process()
            at H5.Compiler.CompilationProcessor.Compile(CompilationRequest compilationRequest, UID128 compilationUID, CancellationToken cancellationToken)
     1>/home/andre/.nuget/packages/h5.target/0.0.11500/Sdk/Sdk.targets(462,9): error MSB3073: The command "h5 --project "/home/andre/RiderProjects/Tetys/csharp/Tetys.Libs.UniGui.Html5/Tetys.Libs.UniGui.Html5.csproj" --configuration "Debug" --assembly-version "1.0.0.0"" exited with code 1.
     1>Done Building Project "/home/andre/RiderProjects/Tetys/csharp/Tetys.Libs.UniGui.Html5/Tetys.Libs.UniGui.Html5.csproj" (build target(s)) -- FAILED.

Build FAILED.

       "/home/andre/RiderProjects/Tetys/csharp/Tetys.Libs.UniGui.Html5/Tetys.Libs.UniGui.Html5.csproj" (build target) (1) ->
       (_H5Build target) -> 
         H5 : error H5003: Could not find file '/home/andre/RiderProjects/Tetys/csharp/Tetys.Libs.UniGui.Core/bin/Debug/netstandard2.0/netstandard.dll'.
         /home/andre/.nuget/packages/h5.target/0.0.11500/Sdk/Sdk.targets(462,9): error MSB3073: The command "h5 --project "/home/andre/RiderProjects/Tetys/csharp/Tetys.Libs.UniGui.Html5/Tetys.Libs.UniGui.Html5.csproj" --configuration "Debug" --assembly-version "1.0.0.0"" exited with code 1.

    0 Warning(s)
    2 Error(s)
@theolivenbaum
Copy link
Collaborator

Hi @IceReaper - do you think you can share with me the code so I can debug locally?

@IceReaper
Copy link
Author

Got any contact information for me, to provide you a code share?

@theolivenbaum
Copy link
Collaborator

theolivenbaum commented Oct 26, 2020 via email

@IceReaper
Copy link
Author

IceReaper commented Oct 28, 2020

I managed to reproduce it on a small scale test project:
H5Test.zip

Both Windows 10 and Ubuntu 20.10 produce the same error.

@theolivenbaum
Copy link
Collaborator

Thanks! I'm going to be off next week but will take a look as soon as I'm back!

@IceReaper IceReaper mentioned this issue Nov 13, 2020
@IceReaper
Copy link
Author

Ongoing from #25: Above error is gone, but now the following error occurs:

H5 : error H5003: Invalid static method invocation syntax: "[MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)', 2)". Method '[MSBuild]::GetTargetFrameworkVersion' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)). Check that all parameters are defined, are of the correct type, and are specified in the right order.  C:\Program Files\dotnet\sdk\5.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets

@theolivenbaum
Copy link
Collaborator

Strange - this last error was supposed to be gone with the update to the h5 SDK target that you've already applied.

By the way, I didn't know referencing libraries that are compiled against the normal C# SDK was supported by Bridge before - I'll take a look on the zip file you shared here

@theolivenbaum
Copy link
Collaborator

So tested here, the issue seems to be referencing a standard csproj:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
    </PropertyGroup>
</Project>

If you change the Library.csproj to be a h5 project:

<Project Sdk="h5.Target/0.0.13615">
    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="h5" Version="0.0.13619" />
    </ItemGroup>
</Project>

Then it compiles fine. Is this possible on your case? If this is code that is shared on your code-base outside of h5, I would recommend having 2 csproj files, one using the standard SDK and one with the h5 SDK.

@IceReaper
Copy link
Author

IceReaper commented Nov 13, 2020

What i have written against bridge originally is the following setup:

  • Ui.Core - netstandard2.0 gl gui library. Instead of calling gl methods, it defines an IGlContext interface.
  • Ui.Desktop - net5, using openTK and implementing the interfaces to call OpenGL
  • Ui.Html5 - netstandard2.0 using h5. It implements the interface by wrapping the stuff into WebGL (hence the webgl2 library)

If i change the Ui.Core project to use the h5 target, i cant build it with Ui.Desktop anymore. Using bridge this setup worked perfectly.

Ill test the 2 csproj files approach for now, if that works out i can go with that solution for now. But on the long term i would love to see the feature back (as this will cause a mess if we add more and more libraries) :)

EDIT: The additional csproj approach works as a workaround for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants