Skip to content

Commit 99fa584

Browse files
Feat/static linking (#19)
* support .NET8 only * using pcap_open_live instead of pcap_open * mitigated some AoT risks * test nuget publish * try again * removed daily tests * fix: Cannot find "_pcap_setbuff" method in libpcap * replaced 'wpcap' with 'libpcap' as the default value to allow static linking in Linux * updated NuGet version * fix Tests
1 parent 11d93df commit 99fa584

20 files changed

+259
-117
lines changed

.circleci/config.yml

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ parameters:
77
sonar-project:
88
type: string
99
default: "Lansweeper_sharppcap"
10-
nuget-output-file:
10+
nuget-output-folder:
1111
type: string
12-
default: "SharpPcap/bin/Release/Lansweeper.SharpPcap.10.0.0-alpha.nupkg"
12+
default: "SharpPcap/bin/Release"
1313

1414
executors:
1515
node:
@@ -31,7 +31,6 @@ commands:
3131
jobs:
3232
build:
3333
executor: win/default
34-
3534
steps:
3635
- checkout
3736
- run:
@@ -44,7 +43,6 @@ jobs:
4443
- run:
4544
name: Upload SonarScanner results
4645
command: dotnet sonarscanner end /d:sonar.login=$Env:SONAR_TOKEN
47-
4846
- persist_to_workspace:
4947
root: .
5048
paths:
@@ -54,6 +52,8 @@ jobs:
5452
executor:
5553
name: win/default
5654
steps:
55+
- attach_workspace:
56+
at: .
5757
- run:
5858
name: Create local nuget config file
5959
command: |
@@ -83,22 +83,15 @@ jobs:
8383
- attach_workspace:
8484
at: .
8585
- run:
86-
name: Set correct version in csproj file, build and pack it
87-
command: |
88-
$env:package_version = "10.0.0-alpha"
89-
90-
$file = Get-Item << pipeline.parameters.csproj-file >>
91-
[xml]$cn = Get-Content $file
92-
$cn.Project.PropertyGroup.Version="$env:package_version"
93-
$cn.Save($file.FullName)
94-
type ./<< pipeline.parameters.csproj-file >>
95-
- run:
96-
name: Pack the package
86+
name: Pack the default package
9787
command: dotnet pack << pipeline.parameters.csproj-file >> --configuration Release
9888
- run:
99-
name: Publish the package
89+
name: Publish the default package
90+
shell: bash
10091
command: |
101-
dotnet nuget push << pipeline.parameters.nuget-output-file >> --source "github" --api-key $env:GITHUB_TOKEN
92+
version=$(grep -o "<Version>[^<]*" << pipeline.parameters.csproj-file >> | sed 's/<Version>//' | head -n 1)
93+
packageid=$(grep -o "<PackageId>[^<]*" << pipeline.parameters.csproj-file >> | sed 's/<PackageId>//' | head -n 1)
94+
dotnet nuget push << pipeline.parameters.nuget-output-folder >>/$packageid.$version.nupkg --source "github" --api-key $GITHUB_TOKEN
10295
10396
sonar:
10497
executor: node
@@ -107,7 +100,7 @@ jobs:
107100
at: .
108101
- sonar-check/get_sonar_status:
109102
report_file: "/home/circleci/project/.sonarqube/out/.sonar/report-task.txt"
110-
103+
111104
workflows:
112105
version: 2
113106

@@ -154,18 +147,4 @@ workflows:
154147
- lec-github-packages-rw
155148
filters:
156149
branches:
157-
only: master
158-
159-
run-daily-tests:
160-
triggers:
161-
- schedule:
162-
cron: "0 0 * * *"
163-
filters:
164-
branches:
165-
only: master
166-
167-
jobs:
168-
- build:
169-
context:
170-
- lec-github-packages-rw
171-
- SonarCloud
150+
only: master

Directory.Build.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ SPDX-License-Identifier: MIT
77
<Deterministic>true</Deterministic>
88
<DebugType>full</DebugType>
99
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
10-
<LangVersion>8.0</LangVersion>
1110
</PropertyGroup>
1211
</Project>

Examples/Example3.BasicCap/Example03.BasicCap.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
44
<TargetFramework>net8.0</TargetFramework>
5+
<PublishTrimmed>true</PublishTrimmed>
56
</PropertyGroup>
67
<ItemGroup>
78
<ProjectReference Include="..\..\SharpPcap\SharpPcap.csproj" />
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project>
6+
<PropertyGroup>
7+
<Configuration>Release</Configuration>
8+
<Platform>Any CPU</Platform>
9+
<PublishDir>.\publish\lin-arm64-aot\</PublishDir>
10+
<PublishProtocol>FileSystem</PublishProtocol>
11+
<_TargetId>Folder</_TargetId>
12+
<TargetFramework>net8.0</TargetFramework>
13+
<RuntimeIdentifier>linux-arm64</RuntimeIdentifier>
14+
<SelfContained>true</SelfContained>
15+
<PublishSingleFile>false</PublishSingleFile>
16+
<PublishAot>true</PublishAot>
17+
</PropertyGroup>
18+
</Project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project>
6+
<PropertyGroup>
7+
<Configuration>Release</Configuration>
8+
<Platform>Any CPU</Platform>
9+
<PublishDir>.\publish\lin-x64-aot\</PublishDir>
10+
<PublishProtocol>FileSystem</PublishProtocol>
11+
<_TargetId>Folder</_TargetId>
12+
<TargetFramework>net8.0</TargetFramework>
13+
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
14+
<SelfContained>true</SelfContained>
15+
<PublishSingleFile>false</PublishSingleFile>
16+
<PublishReadyToRun>false</PublishReadyToRun>
17+
<PublishAot>true</PublishAot>
18+
</PropertyGroup>
19+
</Project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project>
6+
<PropertyGroup>
7+
<Configuration>Release</Configuration>
8+
<Platform>Any CPU</Platform>
9+
<PublishDir>.\publish\lin-x64\</PublishDir>
10+
<PublishProtocol>FileSystem</PublishProtocol>
11+
<_TargetId>Folder</_TargetId>
12+
<TargetFramework>net8.0</TargetFramework>
13+
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
14+
<SelfContained>true</SelfContained>
15+
<PublishSingleFile>true</PublishSingleFile>
16+
<PublishReadyToRun>false</PublishReadyToRun>
17+
</PropertyGroup>
18+
</Project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project>
6+
<PropertyGroup>
7+
<Configuration>Release</Configuration>
8+
<Platform>Any CPU</Platform>
9+
<PublishDir>.\publish\win-x64-aot\</PublishDir>
10+
<PublishProtocol>FileSystem</PublishProtocol>
11+
<_TargetId>Folder</_TargetId>
12+
<TargetFramework>net8.0</TargetFramework>
13+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
14+
<SelfContained>true</SelfContained>
15+
<PublishSingleFile>false</PublishSingleFile>
16+
<PublishReadyToRun>false</PublishReadyToRun>
17+
<PublishAot>true</PublishAot>
18+
</PropertyGroup>
19+
</Project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project>
6+
<PropertyGroup>
7+
<Configuration>Release</Configuration>
8+
<Platform>Any CPU</Platform>
9+
<PublishDir>.\publish\win-x64\</PublishDir>
10+
<PublishProtocol>FileSystem</PublishProtocol>
11+
<_TargetId>Folder</_TargetId>
12+
<TargetFramework>net8.0</TargetFramework>
13+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
14+
<SelfContained>true</SelfContained>
15+
<PublishSingleFile>true</PublishSingleFile>
16+
<PublishReadyToRun>false</PublishReadyToRun>
17+
</PropertyGroup>
18+
</Project>

Examples/WinformsExample/WinformsExample.csproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>WinExe</OutputType>
4-
<TargetFramework>net48</TargetFramework>
4+
<TargetFramework>net8.0-windows</TargetFramework>
5+
<UseWindowsForms>true</UseWindowsForms>
56
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
67
</PropertyGroup>
7-
<ItemGroup>
8-
<Reference Include="System.Data.DataSetExtensions" />
9-
<Reference Include="System.Windows.Forms" />
10-
</ItemGroup>
118
<ItemGroup>
129
<ProjectReference Include="..\..\SharpPcap\SharpPcap.csproj" />
1310
</ItemGroup>

SharpPcap.sln

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.29025.244
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35527.113 d17.12
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example03.BasicCap", "Examples\Example3.BasicCap\Example03.BasicCap.csproj", "{2B5462B9-068B-46E8-B139-E3B9211A48B1}"
77
EndProject
@@ -45,6 +45,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
4545
ProjectSection(SolutionItems) = preProject
4646
.gitattributes = .gitattributes
4747
.gitignore = .gitignore
48+
.circleci\config.yml = .circleci\config.yml
4849
LICENSE = LICENSE
4950
README.md = README.md
5051
EndProjectSection

0 commit comments

Comments
 (0)