diff --git a/dist.ps1 b/dist.ps1
index 0982366..de2d251 100644
--- a/dist.ps1
+++ b/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
@@ -110,4 +86,90 @@ function Build-All
Build-Library -BuildType "Release" -Arch "x64" -LanguageBinding "pinvoke"
Build-Library -BuildType "Debug" -Arch "x64" -LanguageBinding ""
Build-Library -BuildType "Debug" -Arch "x64" -LanguageBinding "pinvoke"
-}
\ No newline at end of file
+}
+
+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'
+}
diff --git a/dist.sh b/dist.sh
index ee27f15..05131c2 100755
--- a/dist.sh
+++ b/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
diff --git a/pkg/nuget/README.md b/pkg/nuget/README.md
new file mode 100644
index 0000000..c7460d7
--- /dev/null
+++ b/pkg/nuget/README.md
@@ -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.
\ No newline at end of file
diff --git a/pkg/nuget/ZeroTier.Sockets/ZeroTier.Sockets.x64.nuspec b/pkg/nuget/ZeroTier.Sockets/ZeroTier.Sockets.x64.nuspec
new file mode 100644
index 0000000..bdf61b8
--- /dev/null
+++ b/pkg/nuget/ZeroTier.Sockets/ZeroTier.Sockets.x64.nuspec
@@ -0,0 +1,33 @@
+
+
+
+ ZeroTier.Sockets
+ 0.0.0
+ ZeroTier, Inc.
+ ZeroTier, Inc.
+ http://github.com/zerotier/libzt
+ LICENSE.txt
+ icon.png
+ false
+ Initial release
+ Encrypted P2P SD-WAN networking layer (Managed C# API) [x64]
+ Encrypted P2P SD-WAN networking layer (Managed C# API) [x64]
+ Copyright 2021 ZeroTier, Inc.
+ p2p networking utility library sdwan socket tcp udp ip encryption vpn sdk zerotier libzt libzerotier native
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pkg/nuget/ZeroTier.Sockets/ZeroTier.Sockets.x86.nuspec b/pkg/nuget/ZeroTier.Sockets/ZeroTier.Sockets.x86.nuspec
new file mode 100644
index 0000000..dd77924
--- /dev/null
+++ b/pkg/nuget/ZeroTier.Sockets/ZeroTier.Sockets.x86.nuspec
@@ -0,0 +1,33 @@
+
+
+
+ ZeroTier.Sockets.x86
+ 0.0.0
+ ZeroTier, Inc.
+ ZeroTier, Inc.
+ http://github.com/zerotier/libzt
+ LICENSE.txt
+ icon.png
+ false
+ Initial release
+ Encrypted P2P SD-WAN networking layer (Managed C# API) [x86]
+ Encrypted P2P SD-WAN networking layer (Managed C# API) [x86]
+ Copyright 2021 ZeroTier, Inc.
+ p2p networking utility library sdwan socket tcp udp ip encryption vpn sdk zerotier libzt libzerotier native
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pkg/nuget/ZeroTier.Sockets/icon.png b/pkg/nuget/ZeroTier.Sockets/icon.png
new file mode 100644
index 0000000..55f65bb
Binary files /dev/null and b/pkg/nuget/ZeroTier.Sockets/icon.png differ
diff --git a/pkg/nuget/ZeroTier.Sockets/readme.txt b/pkg/nuget/ZeroTier.Sockets/readme.txt
new file mode 100644
index 0000000..c04fe02
--- /dev/null
+++ b/pkg/nuget/ZeroTier.Sockets/readme.txt
@@ -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
diff --git a/src/bindings/csharp/README.md b/src/bindings/csharp/README.md
index 3793e1c..82a854c 100644
--- a/src/bindings/csharp/README.md
+++ b/src/bindings/csharp/README.md
@@ -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.
\ No newline at end of file