Skip to content

Add support for nuget package generation #17

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions Directory.Build.props

This file was deleted.

7 changes: 5 additions & 2 deletions examples/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
<PropertyGroup>
<Authors>Christian Kothe</Authors>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>1.12.2</Version>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
</Project>
</Project>

11 changes: 10 additions & 1 deletion liblsl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
<Version>2.0</Version>
<DefaultItemExcludes>$(DefaultItemExcludes);examples/**</DefaultItemExcludes>
<AssemblyName>lsl_csharp</AssemblyName>
<Copyright>Copyright © Christian Kothe 2021</Copyright>
<ProjectUrl>https://github.com/labstreaminglayer/liblsl-Csharp</ProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>LSL Lab Streaming Layer</PackageTags>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<RuntimeIdentifiers>win-x86;win-x64;osx-x64;linux-x64</RuntimeIdentifiers>
</PropertyGroup>
</Project>

<ItemGroup>
<Content Include="runtimes\**" Exclude="runtimes\README.md" PackagePath="runtimes" />
</ItemGroup>
</Project>
65 changes: 65 additions & 0 deletions runtimes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Runtime Identifier Dependencies

The NuGet package for the C# bindings includes binary distributions for major platform runtimes targeted by [liblsl](https://github.com/sccn/liblsl). To successfully build the package, these binaries need to be downloaded from [liblsl releases](https://github.com/sccn/liblsl/releases) and included in this folder following the RID naming conventions outlined in the [RID Catalog](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog).

The following [architecture-specific folders](https://docs.microsoft.com/en-us/nuget/create-packages/supporting-multiple-target-frameworks#architecture-specific-folders) are recommended:

```
\runtimes
\linux-x64
\native
liblsl.so
liblsl.so.1.14.0
\osx-x64
\native
liblsl.dylib
liblsl.1.14.0.dylib
\win-x64
\native
lsl.dll
\win-x86
\native
lsl.dll
```

## Project files for dependent projects

From Visual Studio 2019, both .NET Core (`dotnet`) and .NET Framework compilers will use the `RuntimeIdentifier` element of the new SDK csproj format to control which native dependencies to deploy to the final output folder.

### .NET Core
In .NET Core, the default is to generate cross-platform deployments, which means that all the runtimes will be deployed to the final output folder. By inserting a specific `RuntimeIdentifier` a build targeting only the specified architecture is generated.

```xml
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<!--<RuntimeIdentifier>linux-x64</RuntimeIdentifier>-->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="lsl_csharp" Version="2.0.0" />
</ItemGroup>

</Project>
```

### .NET Framework
In legacy .NET framework projects, `RuntimeIdentifier` defaults to `win7-x86` which has the generic fallback to `win-x86`. Therefore, the above folder structure will automatically copy `lsl.dll` into the output folder of .NET Framework projects.

```xml
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
<!--<RuntimeIdentifier>win-x64</RuntimeIdentifier>-->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="lsl_csharp" Version="2.0.0" />
</ItemGroup>

</Project>
```