Giter Club home page Giter Club logo

dotnet-native's People

Contributors

mizux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dotnet-native's Issues

Adapting this template for a submodule'd library

I'm trying to write bindings for a C/C++ library which I don't control. I've included that library, as is, as a submodule in this repo.

I'm trying to adapt this template so that the bindings can be a sibling of the library folder, rather than a child (so it works with a submodule). That is:

this template:
├─ Foo/
│  ├─ CMakeLists.txt
│  ├─ dotnet/
│  │  ├─ CMakeLists.txt

mine:
├─ Foo/
│  ├─ CMakeLists.txt
├─ Foo.dotnet/
│  ├─ CMakeLists.txt

Right now, it's failing because the swig-generated wrapper doesn't have access to the header file.

[build] C:\whisper.dotnet\build\dotnet\NickDarvey.Whisper\Whisper\whisperCSHARP_wrap.cxx(766,10): fatal  error C1083: Cannot open include file: 'whisper.cpp/whisper.h': No such file or directory [C:\whisper.dotnet\build\whisper.cpp.dotnet\dotnet_whisper.vcxproj]

When I build this (mizux/dotnet-native) repo with Visual Studio 2022 kit selected it generates a build\Foo\dotnet\dotnet_Foo.vcxproj which has:

  1. The include folder (containing the header) as an AdditionalIncludeDirectories
    <AdditionalIncludeDirectories>C:\dotnet-native\Foo\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    
  2. The includes folder as an argument to swig.exe
    [...]swig.exe -csharp -IC:/dotnet-native -IC:/dotnet-native/dotnet -IC:/dotnet-native/Foo/include -namespace Mizux.DotnetNative.Foo -dllimport mizux-dotnetnative-native -outdir C:/dotnet-native/build/dotnet/Mizux.DotnetNative/Foo -c++ -o C:/dotnet-native/build/dotnet/Mizux.DotnetNative/Foo/fooCSHARP_wrap.cxx C:/dotnet-native/Foo/dotnet/foo.i
    

When I (attempt) to build my (nickdarvey/whisper.dotnet) it generates a vcxproj which has neither of those. I think that's why I'm getting that error.

Are you able to help me get the location of my header files, ./whisper.cpp, to appear in AdditionalIncludeDirectories?

Cannot PackageReference Mizux.Foo

I have a C++ library with NetStandard2.0 wrapper; this library has specialized builds for Windows, Linux and MacOS. I can generate the .Net wrapper and shared library which is specific for each platform only on this platform (i.e. no cross compilation).

note: You can find this example at: https://github.com/Mizux/dotnet

Native OS library: Mizux.Foo.*-x64.nupkg

On Linux-x64:

Native.cpp -> Native.so -------+
Native.cpp -> Native.linux.cs -+-> Foo.linux-x64.csproj -> Mizux.Foo.linux-x64.npkg

src: https://github.com/Mizux/dotnet/blob/master/src/Foo.linux-x64/Foo.linux-x64.csproj

On osx-x64:

Native.cpp -> Native.dylib --+
Native.cpp -> Native.osx.cs -+-> Foo.osx-x64.csproj -> Mizux.Foo.osx-x64.npkg

src: https://github.com/Mizux/dotnet/blob/master/src/Foo.osx-x64/Foo.osx-x64.csproj

On win-x64:

Native.cpp -> Native.dll ----+
Native.cpp -> Native.win.cs -+-> Foo.win-x64.csproj -> Mizux.Foo.win-x64.npkg

src: https://github.com/Mizux/dotnet/blob/master/src/Foo.win-x64/Foo.win-x64.csproj

So I can generate native package one each OS for this OS.

Question 1: Does my nuget package layout correct ?

unzip -l package/Mizux.Foo.linux-x64.1.0.0.nupkg
Archive:  package/Mizux.Foo.linux-x64.1.0.0.nupkg
  Length      Date    Time    Name
---------  ---------- -----   ----
      509  2018-08-14 15:47   _rels/.rels
      498  2018-08-14 15:47   Mizux.Foo.linux-x64.nuspec
     3584  2018-08-14 13:33   runtimes/linux-x64/lib/netstandard2.0/Mizux.Foo.linux-x64.dll # .CS which load the native.so -> should be in the same repository
        0  2018-08-09 12:04   runtimes/linux-x64/lib/netstandard2.0/native.so
      520  2018-08-14 15:47   [Content_Types].xml
      633  2018-08-14 15:47   package/services/metadata/core-properties/d5f8836b446941b1a8eb822b3c4e009c.psmdcp
---------                     -------
     5744                     6 files

So here I put files in runtimes/linux-x64/lib/netstandard2.0 but when building with: dotnet build --runtime win-x64 src/Foo.linux-x64 file are placed in [bin/Debug/]netstandard2.0/linux-x64/* So do I need to place files in lib/linux-x64/netstandard2.0 instead ?

Meta-Package: Mizux.Foo.nupkg

Then I want to create a meta-package Mizux.Foo containing the three dependencies as PackageReference (supposing I copy past all generated in a local package folder).

package/Mizux.Foo.linux-x64.nupkg -+
package/Mizux.Foo.osx-x64.nupkg ---+-(PackageReference)> Foo.csproj -> Mizux.Foo.nupkg
package/Mizux.Foo.win-x64.nupkg ---+

src: https://github.com/Mizux/dotnet/blob/master/src/Foo/Foo.csproj

I manage to create the nupkg with the .csproj and Mizux.Foo.nuspec inside the nuget package contains:

<dependencies>
  <group targetFramework=".NETStandard2.0">
    <dependency id="Mizux.Foo.linux-x64" version="1.0.0" exclude="Build,Analyzers" />
    <dependency id="Mizux.Foo.osx-x64" version="1.0.0" exclude="Build,Analyzers" />
    <dependency id="Mizux.Foo.win-x64" version="1.0.0" exclude="Build,Analyzers" />
  </group>
</dependencies>

FooApp using Foo.csproj

So far so good ???
I manage to build a FooApp if I use ProjectReference on Foo.csproj and condition on RuntimeIdentifier i.e.

dotnet build --runtime linux-x64 src/FooApp
dotnet src/FooApp/bin/Debug/netcoreapp2.1/linux-x64/Mizux.FooApp.dll

src: https://github.com/Mizux/dotnet/blob/master/src/FooApp/FooApp.csproj

This works but in fact it create a degenerated project where Foo.osx-x64 and Foo.win-x64 are ignored (which is cool when testing locally but not when building the meta-package...)

side note: dotnet run --runtime linux-x64 --project src/FooApp won't work since RuntimeIdentifier is ignored, so it try to rebuild as pure .Net project and look in bin/debug/netstandard2.0...

Example using Mizux.Foo.nupkg

So far so good ???
So now I now I want to create a Example which PackageReference Mizux.Foo package...

dotnet build -r linux-x64 example/Example
Program.cs(8,7): error CS0103: The name 'Foo' does not exist in the current context [/usr/local/google/home/corentinl/work/dotnet/example/Example/Example.csproj]
Build FAILED.

src: https://github.com/Mizux/dotnet/blob/master/example/Example/Example.csproj

Question 2: What's wrong here why example don't see the runtimes dir ?

Question 3: It's seems Foo doesn't expose Foo.*-x64 i.e. transitivity not working, why ?

XCode `dotnet build` failure

When trying to run dotnet build all output .dll are renamed

e.g. dotnet package use AssemblyName:

<AssemblyName>@DOTNET_PROJECT@</AssemblyName>

which is
set(DOTNET_PACKAGE Mizux.DotnetNative)

so with any generator but XCode we got dotnet cli generating the command with arg /out:obj/x64/Release/net6.0/Mizux.DotnetNative.dll but Xcode export the env TARGETNAME=dotnet_package leading to the dotnet internal build command replaced by /out:obj/x64/Release/net6.0/dotnet_package.dll

This impact build, pack, test and run command AFAIK

How to change name of library

Hi Mizux

I tried to generalize your setup a bit fill out the missing parts of the .csproj.in packages. Something that I cannot get my head around are:

I removed the NuGet repository to avoid uploading to nuget.org, such that RestoreSources only contains a local package dir. Do I need to upload stuff or can I use a local directory?

I can build everything but not execute the C# tests. It insists on naming stuff Mizux and DotNetNative but only runtime.

Can't run dotnet using Xcode generator

When using the -G "Xcode" generator, it seems we can't run the samples from CTest.

It seems dotnet didn't succeed to find all its dependencies

A fatal error was encountered. The library 'libhostpolicy.dylib' required to execute the application was not found in '...'.

ref: https://github.com/Mizux/dotnet-native/runs/670363781?check_suite_focus=true

note: When using the default make generator, everything work flawlessly
see: https://github.com/Mizux/dotnet-native/runs/670363803?check_suite_focus=true

.NET48

Have you tried building it using .NET48. At least on Windows, I get numerous errors about incompatibility on the given platform. The framework is for sure installed. We are still stuck on .NET48

Native runtime packages compatible with .NET Framework (AnyCPU)?

How can I produce runtime packages compatible with .NET Framework?

I tried to change the framework identified netcoreapp3.1 to netstandard2.0 or net461 but I failed to produce working examples.

The reason why I fail to run the examples is that there are no native DLLs copied to the binary space for the example project:

Analysis of the differences:

  • Working with netcoreapp3.1: The folder \dotnet\examples\Example\bin\Debug\netcoreapp3.1 contains a subfolder runtimes\win-x64\native with the native DLLs.
  • Not Working with standard2.0: The folder \dotnet\examples\Example\bin\Debug\netstandard2.0 contains no native DLLS and neither a subfolder runtimes subfolder

The nuspec files for the wrapper and native package are the same except for the targetFramework identifier.

Are runtime packages restricted to .NET core and .NET 5.0+ ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.