Add NuGet package and build scripts
This commit is contained in:
142
dist.ps1
142
dist.ps1
@@ -1,49 +1,24 @@
|
||||
function CreateNugetPackage
|
||||
{
|
||||
md builds\pkg\nuget -Force
|
||||
|
||||
# runtimes
|
||||
md pkg\nuget\ZeroTier.Sockets\runtimes\win10-x86\native -Force
|
||||
md pkg\nuget\ZeroTier.Sockets\runtimes\win10-x64\native -Force
|
||||
md pkg\nuget\ZeroTier.Sockets\runtimes\win10-x64\lib\uap10.0 -Force
|
||||
md pkg\nuget\ZeroTier.Sockets\runtimes\win10-arm\native -Force
|
||||
|
||||
# frameworks
|
||||
md pkg\nuget\ZeroTier.Sockets\lib\net48 -Force
|
||||
md pkg\nuget\ZeroTier.Sockets\lib\net5.0 -Force
|
||||
|
||||
# Build native libzt with exported P/INVOKE symbols
|
||||
Build-Library -BuildType "Release" -Arch "x64" -LanguageBinding "csharp"
|
||||
Build-Library -BuildType "Release" -Arch "x64" -LanguageBinding ""
|
||||
|
||||
Build-Library -BuildType "Release" -Arch "Win32" -LanguageBinding "csharp"
|
||||
#Build-Library -BuildType "Release" -Arch "ARM" -LanguageBinding "csharp"
|
||||
|
||||
# Copy assemblies into NuGet package tree
|
||||
Copy-Item .\lib\release\win-x64-pinvoke\*.dll pkg\nuget\ZeroTier.Sockets\runtimes\win10-x64\lib\uap10.0\libzt.dll
|
||||
Copy-Item .\lib\release\win-x64\*.dll pkg\nuget\ZeroTier.Sockets\runtimes\win10-x64\native\libzt.dll
|
||||
|
||||
Copy-Item .\lib\release\win-x86-pinvoke\*.dll pkg\nuget\ZeroTier.Sockets\runtimes\win10-x86\native\libzt.dll
|
||||
#Copy-Item .\lib\release\win-arm-pinvoke\*.dll pkg\nuget\ZeroTier.Sockets\runtimes\win10-arm\native\libzt.dll
|
||||
|
||||
# Build wrapper library for C# ZeroTier.Sockets abstraction
|
||||
csc -target:library -out:pkg\nuget\ZeroTier.Sockets\lib\net5.0\ZeroTier.Sockets.dll .\src\bindings\csharp\*.cs
|
||||
|
||||
# Package everything
|
||||
Push-Location -Path pkg\nuget\ZeroTier.Sockets
|
||||
|
||||
del ZeroTier.Sockets.*.nupkg
|
||||
nuget pack ZeroTier.Sockets.nuspec -OutputDirectory ..\..\..\builds\pkg\nuget
|
||||
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
function Clean
|
||||
{
|
||||
Remove-Item builds -Recurse -Force -Confirm:$false -ErrorAction:'silentlycontinue'
|
||||
Remove-Item tmp -Recurse -Force -Confirm:$false -ErrorAction:'silentlycontinue'
|
||||
Remove-Item lib -Recurse -Force -Confirm:$false -ErrorAction:'silentlycontinue'
|
||||
Remove-Item bin -Recurse -Force -Confirm:$false -ErrorAction:'silentlycontinue'
|
||||
# pkg
|
||||
Clean-PackageDirectory
|
||||
Get-ChildItem pkg -recurse -include *.dll | remove-item
|
||||
Get-ChildItem pkg -recurse -include *.lib | remove-item
|
||||
Get-ChildItem pkg -recurse -include *.pdb | remove-item
|
||||
Get-ChildItem pkg -recurse -include *.nupkg | remove-item
|
||||
# src
|
||||
Get-ChildItem src -recurse -include *.dll | remove-item
|
||||
Get-ChildItem src -recurse -include *.lib | remove-item
|
||||
Get-ChildItem src -recurse -include *.pdb | remove-item
|
||||
Get-ChildItem src -recurse -include *.dylib | remove-item
|
||||
Get-ChildItem src -recurse -include *.so | remove-item
|
||||
Get-ChildItem src -recurse -include *.exe | remove-item
|
||||
Get-ChildItem src -recurse -include *.out | remove-item
|
||||
Get-ChildItem src -recurse -include *.a | remove-item
|
||||
}
|
||||
|
||||
function Build-Library([string]$BuildType, [string]$Arch, [string]$LanguageBinding)
|
||||
@@ -96,6 +71,7 @@ function Build-Library([string]$BuildType, [string]$Arch, [string]$LanguageBindi
|
||||
Pop-Location
|
||||
Copy-Item $env:BuildDir\$BuildType\zt.lib $env:OutputDir\$archAlias$LanguageBindingPostfix\libzt$bitCount.lib
|
||||
Copy-Item $env:BuildDir\$BuildType\zt-shared.dll $env:OutputDir\$archAlias$LanguageBindingPostfix\libzt$bitCount.dll
|
||||
Copy-Item $env:BuildDir\$BuildType\zt-shared.pdb $env:OutputDir\$archAlias$LanguageBindingPostfix\libzt$bitCount.pdb
|
||||
}
|
||||
|
||||
function Build-All
|
||||
@@ -111,3 +87,89 @@ function Build-All
|
||||
Build-Library -BuildType "Debug" -Arch "x64" -LanguageBinding ""
|
||||
Build-Library -BuildType "Debug" -Arch "x64" -LanguageBinding "pinvoke"
|
||||
}
|
||||
|
||||
function BuildNuGetPackages([string]$Version)
|
||||
{
|
||||
BuildNuGetPackage-Sockets -BuildType "Release" -Arch "x64" -Version $Version
|
||||
BuildNuGetPackage-Sockets -BuildType "Debug" -Arch "x64" -Version $Version
|
||||
BuildNuGetPackage-Sockets -BuildType "Release" -Arch "Win32" -Version $Version
|
||||
BuildNuGetPackage-Sockets -BuildType "Debug" -Arch "Win32" -Version $Version
|
||||
}
|
||||
|
||||
function BuildNuGetPackage-Sockets([string]$BuildType, [string]$Arch, [string]$Version)
|
||||
{
|
||||
$archAlias = $Arch
|
||||
if ($Arch -eq "Win32") {
|
||||
$archAlias="x86"
|
||||
}
|
||||
|
||||
md pkg\nuget\ZeroTier.Sockets\bin\ -Force
|
||||
md builds\pkg\nuget\$($BuildType.ToLower())\$archAlias -Force
|
||||
del builds\pkg\nuget\$($BuildType.ToLower())\$archAlias\*.nupkg -ErrorAction:'silentlycontinue'
|
||||
|
||||
# licenses
|
||||
md pkg\nuget\ZeroTier.Sockets\licenses -Force
|
||||
Copy-Item LICENSE.txt pkg\nuget\ZeroTier.Sockets\licenses
|
||||
|
||||
# contentFiles (sources)
|
||||
md pkg\nuget\ZeroTier.Sockets\contentFiles -Force
|
||||
Copy-Item src\bindings\csharp\*.cs pkg\nuget\ZeroTier.Sockets\contentFiles
|
||||
|
||||
# Where we plan to output *.nupkg(s)
|
||||
md builds\pkg\nuget\$($BuildType.ToLower()) -Force
|
||||
|
||||
# runtimes
|
||||
md pkg\nuget\ZeroTier.Sockets\runtimes\win10-$archAlias\native -Force
|
||||
md pkg\nuget\ZeroTier.Sockets\runtimes\win10-$archAlias\lib\uap10.0 -Force
|
||||
#md pkg\nuget\ZeroTier.Sockets\runtimes\win10-arm\native -Force
|
||||
|
||||
# Build wrapper library for C# ZeroTier.Sockets abstraction
|
||||
csc -target:library -debug:pdbonly -pdb:pkg\nuget\ZeroTier.Sockets\bin\ZeroTier.Sockets.pdb -out:pkg\nuget\ZeroTier.Sockets\bin\ZeroTier.Sockets.dll .\src\bindings\csharp\*.cs
|
||||
|
||||
# Build unmanaged native libzt.dll with exported P/INVOKE symbols
|
||||
Build-Library -BuildType $BuildType -Arch $Arch -LanguageBinding "csharp"
|
||||
Copy-Item .\lib\$($BuildType.ToLower())\win-$archAlias-pinvoke\*.dll pkg\nuget\ZeroTier.Sockets\bin\libzt.dll
|
||||
|
||||
# .NET Framework
|
||||
md pkg\nuget\ZeroTier.Sockets\lib\net40 -Force
|
||||
md pkg\nuget\ZeroTier.Sockets\lib\net403 -Force
|
||||
md pkg\nuget\ZeroTier.Sockets\lib\net45 -Force
|
||||
md pkg\nuget\ZeroTier.Sockets\lib\net451 -Force
|
||||
md pkg\nuget\ZeroTier.Sockets\lib\net452 -Force
|
||||
md pkg\nuget\ZeroTier.Sockets\lib\net46 -Force
|
||||
md pkg\nuget\ZeroTier.Sockets\lib\net461 -Force
|
||||
md pkg\nuget\ZeroTier.Sockets\lib\net462 -Force
|
||||
md pkg\nuget\ZeroTier.Sockets\lib\net47 -Force
|
||||
md pkg\nuget\ZeroTier.Sockets\lib\net471 -Force
|
||||
md pkg\nuget\ZeroTier.Sockets\lib\net472 -Force
|
||||
md pkg\nuget\ZeroTier.Sockets\lib\net48 -Force
|
||||
|
||||
# .NET "Core" 5.0 (moniker missing from microsoft documentation?)
|
||||
md pkg\nuget\ZeroTier.Sockets\lib\net5.0 -Force
|
||||
|
||||
# Copy assemblies into framework-specific directories.
|
||||
$folders = Get-ChildItem pkg\nuget\ZeroTier.Sockets\lib\
|
||||
foreach ($folder in $folders.name){
|
||||
Copy-Item -Path "pkg\nuget\ZeroTier.Sockets\bin\*.*" -Destination "pkg\nuget\ZeroTier.Sockets\lib\$folder" -Recurse
|
||||
}
|
||||
|
||||
# Native DLL placement
|
||||
Copy-Item .\lib\$($BuildType.ToLower())\win-$archAlias-pinvoke\*.dll pkg\nuget\ZeroTier.Sockets\runtimes\win10-$archAlias\lib\uap10.0\libzt.dll
|
||||
Copy-Item .\lib\$($BuildType.ToLower())\win-$archAlias-pinvoke\*.dll pkg\nuget\ZeroTier.Sockets\lib\net40\libzt.dll
|
||||
Copy-Item .\lib\$($BuildType.ToLower())\win-$archAlias-pinvoke\*.dll pkg\nuget\ZeroTier.Sockets\runtimes\win10-$archAlias\native\libzt.dll
|
||||
Copy-Item .\lib\$($BuildType.ToLower())\win-$archAlias-pinvoke\*.pdb pkg\nuget\ZeroTier.Sockets\runtimes\win10-$archAlias\lib\uap10.0\libzt.pdb
|
||||
|
||||
# Package
|
||||
Push-Location -Path pkg\nuget\ZeroTier.Sockets
|
||||
nuget pack ZeroTier.Sockets.$archAlias.nuspec -Version $Version -OutputDirectory ..\..\..\builds\pkg\nuget\$($BuildType.ToLower())\$archAlias
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
function Clean-PackageDirectory
|
||||
{
|
||||
Remove-Item pkg\nuget\ZeroTier.Sockets\lib -Recurse -Force -Confirm:$false -ErrorAction:'silentlycontinue'
|
||||
Remove-Item pkg\nuget\ZeroTier.Sockets\contentFiles -Recurse -Force -Confirm:$false -ErrorAction:'silentlycontinue'
|
||||
Remove-Item pkg\nuget\ZeroTier.Sockets\licenses -Recurse -Force -Confirm:$false -ErrorAction:'silentlycontinue'
|
||||
Remove-Item pkg\nuget\ZeroTier.Sockets\runtimes -Recurse -Force -Confirm:$false -ErrorAction:'silentlycontinue'
|
||||
Remove-Item pkg\nuget\ZeroTier.Sockets\bin -Recurse -Force -Confirm:$false -ErrorAction:'silentlycontinue'
|
||||
}
|
||||
|
||||
6
dist.sh
6
dist.sh
@@ -388,11 +388,11 @@ clean_post_build()
|
||||
clean()
|
||||
{
|
||||
# Remove all temporary build files, products, etc
|
||||
rm -rf tmp lib bin products
|
||||
rm -rf builds tmp lib bin products
|
||||
rm -f *.o *.s *.exp *.lib *.core core
|
||||
# Generally search for and remove object files, libraries, etc
|
||||
find . -path './*_products' -prune -type f \( -name '*.dylib' -o -name '*.so' -o -name \
|
||||
'*.a' -o -name '*.o' -o -name '*.o.d' -o -name \
|
||||
find . -path './*_products' -prune -type f \( -name '*.dylib' -o -name '*.dll' -o -name '*.so' -o -name \
|
||||
'*.a' -o -name '*.o' -o -name '*.exe' -o -name '*.o.d' -o -name \
|
||||
'*.out' -o -name '*.log' -o -name '*.dSYM' -o -name '*.class' \) -delete
|
||||
# Remove any sources copied to project directories
|
||||
rm -rf ports/android/app/src/main/java/com/zerotier/libzt/*.java
|
||||
|
||||
17
pkg/nuget/README.md
Normal file
17
pkg/nuget/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# NuGet package
|
||||
|
||||
Install from [NuGet gallery package]() (recommended):
|
||||
|
||||
```powershell
|
||||
Install-Package ZeroTier.Sockets
|
||||
```
|
||||
|
||||
Install from local package
|
||||
|
||||
```powershell
|
||||
Install-Package ZeroTier.Sockets -Source C:\PathToThePackageDir\
|
||||
```
|
||||
|
||||
Development notes
|
||||
|
||||
- Microsoft's own documentation on multi-architecture nupkgs was outdated and Marco Siccardi seemed to have [the only correct instructions found anywhere on the internet](https://msicc.net/how-to-create-a-multi-architecture-nuget-package-from-a-uwp-class-library/) to accomplish this.
|
||||
33
pkg/nuget/ZeroTier.Sockets/ZeroTier.Sockets.x64.nuspec
Normal file
33
pkg/nuget/ZeroTier.Sockets/ZeroTier.Sockets.x64.nuspec
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>ZeroTier.Sockets</id>
|
||||
<version>0.0.0</version>
|
||||
<authors>ZeroTier, Inc.</authors>
|
||||
<owners>ZeroTier, Inc.</owners>
|
||||
<projectUrl>http://github.com/zerotier/libzt</projectUrl>
|
||||
<license type="file">LICENSE.txt</license>
|
||||
<icon>icon.png</icon>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<releaseNotes>Initial release</releaseNotes>
|
||||
<description>Encrypted P2P SD-WAN networking layer (Managed C# API) [x64]</description>
|
||||
<title>Encrypted P2P SD-WAN networking layer (Managed C# API) [x64]</title>
|
||||
<copyright>Copyright 2021 ZeroTier, Inc.</copyright>
|
||||
<tags>p2p networking utility library sdwan socket tcp udp ip encryption vpn sdk zerotier libzt libzerotier native</tags>
|
||||
<repository type="git" url="https://github.com/zerotier/libzt" />
|
||||
<contentFiles>
|
||||
<files include="cs/**/*.*" buildAction="None" flatten="false" copyToOutput="true"/>
|
||||
</contentFiles>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="readme.txt" target="" />
|
||||
<file src="icon.png" target="" />
|
||||
<file src="lib\**" target="lib" />
|
||||
<file src="runtimes\**" target="runtimes" />
|
||||
<file src="licenses\LICENSE.txt" target="" />
|
||||
<file src="runtimes\win10-x64\lib\uap10.0\*.dll" target="ref\uap10.0" />
|
||||
<file src="contentFiles\*.cs" target="contentFiles\cs\any\ZeroTier.Source.ReadOnly" />
|
||||
<file src="runtimes\win10-x64\lib\uap10.0\*.dll" target="build" />
|
||||
<file src="runtimes\win10-x64\native\*.dll" target="ref\native" />
|
||||
</files>
|
||||
</package>
|
||||
33
pkg/nuget/ZeroTier.Sockets/ZeroTier.Sockets.x86.nuspec
Normal file
33
pkg/nuget/ZeroTier.Sockets/ZeroTier.Sockets.x86.nuspec
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>ZeroTier.Sockets.x86</id>
|
||||
<version>0.0.0</version>
|
||||
<authors>ZeroTier, Inc.</authors>
|
||||
<owners>ZeroTier, Inc.</owners>
|
||||
<projectUrl>http://github.com/zerotier/libzt</projectUrl>
|
||||
<license type="file">LICENSE.txt</license>
|
||||
<icon>icon.png</icon>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<releaseNotes>Initial release</releaseNotes>
|
||||
<description>Encrypted P2P SD-WAN networking layer (Managed C# API) [x86]</description>
|
||||
<title>Encrypted P2P SD-WAN networking layer (Managed C# API) [x86]</title>
|
||||
<copyright>Copyright 2021 ZeroTier, Inc.</copyright>
|
||||
<tags>p2p networking utility library sdwan socket tcp udp ip encryption vpn sdk zerotier libzt libzerotier native</tags>
|
||||
<repository type="git" url="https://github.com/zerotier/libzt" />
|
||||
<contentFiles>
|
||||
<files include="cs/**/*.*" buildAction="None" flatten="false" copyToOutput="true"/>
|
||||
</contentFiles>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="readme.txt" target="" />
|
||||
<file src="icon.png" target="" />
|
||||
<file src="lib\**" target="lib" />
|
||||
<file src="runtimes\**" target="runtimes" />
|
||||
<file src="licenses\LICENSE.txt" target="" />
|
||||
<file src="runtimes\win10-x86\lib\uap10.0\*.dll" target="ref\uap10.0" />
|
||||
<file src="contentFiles\*.cs" target="contentFiles\cs\any\ZeroTier.Source.ReadOnly" />
|
||||
<file src="runtimes\win10-x86\lib\uap10.0\*.dll" target="build" />
|
||||
<file src="runtimes\win10-x86\native\*.dll" target="ref\native" />
|
||||
</files>
|
||||
</package>
|
||||
BIN
pkg/nuget/ZeroTier.Sockets/icon.png
Normal file
BIN
pkg/nuget/ZeroTier.Sockets/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
45
pkg/nuget/ZeroTier.Sockets/readme.txt
Normal file
45
pkg/nuget/ZeroTier.Sockets/readme.txt
Normal file
@@ -0,0 +1,45 @@
|
||||
-------------------------------------------------------------------------------
|
||||
ZeroTier.Sockets (libzt) --- Encrypted P2P SD-WAN networking layer
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
With ZeroTier's SDK you can embed a ZeroTier node into your application and
|
||||
communicate with other ZeroTier nodes (or non-ZeroTier devices bridged onto a
|
||||
ZeroTier network) securely within your own software-defined virtual network.
|
||||
|
||||
C# API:
|
||||
|
||||
- Guide: https://github.com/zerotier/libzt/tree/master/examples/csharp
|
||||
|
||||
This package presents a managed .NET-style Socket API. It is designed as
|
||||
a drop-in replacement for System.Net.Sockets. This is the easiest and most
|
||||
idiomatic way to use ZeroTier in a C# application.
|
||||
|
||||
Self-hosting:
|
||||
|
||||
ZeroTier operates a hosted service (https://my.zerotier.com) that lets you
|
||||
manage your virtual networks. If however you would like to self-host we make
|
||||
that possible too:
|
||||
|
||||
- https://github.com/zerotier/ZeroTierOne/tree/master/controller
|
||||
|
||||
Other API options:
|
||||
|
||||
We offer two other API layers depending on your use case. The first is a lower-
|
||||
level BSD-style socket API. This API is similar to BSD-style sockets
|
||||
(zts_socket(), zts_listen(), zts_bind(), etc.) The second is a Highly-
|
||||
performant virtual Ethernet layer. It can be used for any transport protocol
|
||||
and is only recommended for those who have advanced or specialty applications.
|
||||
|
||||
Bug?
|
||||
|
||||
You should let us know so we can fix it. Please open a github issue here:
|
||||
|
||||
- https://www.github.com/zerotier/libzt
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
LINKS
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- Documentation and bug reports: https://www.github.com/zerotier/libzt
|
||||
- Website: https://www.zerotier.com
|
||||
- Community: https://discuss.zerotier.com
|
||||
@@ -2,3 +2,7 @@
|
||||
|
||||
- Install (via [NuGet package](https://www.nuget.org/packages/ZeroTier.Sockets/)): `Install-Package ZeroTier.Sockets`
|
||||
- Example usage: [examples/csharp](./../../../examples/csharp/)
|
||||
|
||||
# Development Notes
|
||||
|
||||
- The SWIG interface file `zt.i` is only present for historical reference purposes. SWIG generates a ton of unnecessary boilerplate code which is hard to completely prevent by using hints. You can generate a new wrapper for yourself using `swig -c++ -csharp -dllimport "./libzt.so" zt.i` but I would not recommend doing so unless you know what you're in for.
|
||||
Reference in New Issue
Block a user