Skip to content
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
9 changes: 9 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,12 @@ jobs:
build-types: "[ 'Debug' ]"
test: true
preset-name: 'cicd'

dotnet-tests:
name: .NET Tests
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-dotnet-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
uses: ./.github/workflows/dotnet-tests.yml
97 changes: 97 additions & 0 deletions .github/workflows/dotnet-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: '.NET Tests 🧪'

on:
workflow_dispatch:
workflow_call:
push:
branches:
- develop
- main
paths:
- 'api/dotnet/**'
- 'api/protos/**'
- 'tests/integration/dotnet/**'
- '.github/workflows/dotnet-tests.yml'
pull_request:
branches:
- develop
- main
paths:
- 'api/dotnet/**'
- 'api/protos/**'
- 'tests/integration/dotnet/**'
- '.github/workflows/dotnet-tests.yml'

jobs:
dotnet-build:
name: Build .NET API Bindings
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Restore dependencies
run: dotnet restore api/dotnet/NetRemoteClient.csproj

- name: Build
run: dotnet build api/dotnet/NetRemoteClient.csproj --configuration Release --no-restore

- name: Pack NuGet package
run: dotnet pack api/dotnet/NetRemoteClient.csproj --configuration Release --no-build --output ./artifacts

- name: Upload NuGet package artifact
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: ./artifacts/*.nupkg
retention-days: 7

dotnet-integration-tests:
name: .NET Integration Tests
runs-on: ubuntu-latest
needs: dotnet-build
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Restore dependencies
run: dotnet restore tests/integration/dotnet/NetRemoteClient.IntegrationTests.csproj

- name: Build
run: dotnet build tests/integration/dotnet/NetRemoteClient.IntegrationTests.csproj --configuration Release --no-restore

- name: Run integration tests
run: dotnet test tests/integration/dotnet/NetRemoteClient.IntegrationTests.csproj --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx"

- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: dotnet-test-results
path: tests/integration/dotnet/TestResults/*.trx
retention-days: 7

dotnet-tests-windows:
name: .NET Tests (Windows)
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Build and test
run: dotnet test tests/integration/dotnet/NetRemoteClient.IntegrationTests.csproj --configuration Release --verbosity normal
3 changes: 3 additions & 0 deletions api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ install(
if (NOT NETREMOTE_EXCLUDE_API_BINDINGS)
add_subdirectory(protocol)
endif()

# .NET API bindings (NuGet package)
add_subdirectory(dotnet)
7 changes: 7 additions & 0 deletions api/dotnet/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Build outputs
bin/
obj/

# IDE
.vs/
*.user
65 changes: 65 additions & 0 deletions api/dotnet/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# CMake integration for NuGet package building
# This file provides targets for building and packing the NetRemote client NuGet package

find_program(DOTNET_EXECUTABLE dotnet)

if(NOT DOTNET_EXECUTABLE)
message(WARNING "dotnet CLI not found. NuGet package targets will not be available.")
return()
endif()

set(NUGET_PROJECT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/NetRemoteClient.csproj")
set(NUGET_OUTPUT_DIR "${CMAKE_SOURCE_DIR}/out/nuget")

# Update the version in the .csproj file based on the project version
set(NUGET_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

# Custom target to restore NuGet package dependencies
add_custom_target(nuget-restore
COMMAND ${DOTNET_EXECUTABLE} restore "${NUGET_PROJECT_FILE}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Restoring NuGet package dependencies..."
VERBATIM
)

# Custom target to build the NuGet package project
add_custom_target(nuget-build
COMMAND ${DOTNET_EXECUTABLE} build "${NUGET_PROJECT_FILE}" -c Release
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS nuget-restore
COMMENT "Building NetRemote client library..."
VERBATIM
)

# Custom target to create the NuGet package
add_custom_target(nuget-pack
COMMAND ${DOTNET_EXECUTABLE} pack "${NUGET_PROJECT_FILE}"
-c Release
-o "${NUGET_OUTPUT_DIR}"
-p:Version=${NUGET_VERSION}
--no-build
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS nuget-build
COMMENT "Creating NuGet package Microsoft.Net.Remote.Client ${NUGET_VERSION}..."
VERBATIM
)

# Custom target to clean NuGet build artifacts
add_custom_target(nuget-clean
COMMAND ${DOTNET_EXECUTABLE} clean "${NUGET_PROJECT_FILE}" -c Release
COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_CURRENT_SOURCE_DIR}/bin"
COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_CURRENT_SOURCE_DIR}/obj"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Cleaning NuGet build artifacts..."
VERBATIM
)

# Add a convenience target that does everything
add_custom_target(nuget ALL
DEPENDS nuget-pack
COMMENT "NuGet package build complete"
)

message(STATUS "NuGet packaging enabled. Use 'cmake --build . --target nuget-pack' to create the package.")
message(STATUS "NuGet package version: ${NUGET_VERSION}")
message(STATUS "NuGet output directory: ${NUGET_OUTPUT_DIR}")
100 changes: 100 additions & 0 deletions api/dotnet/NetRemoteClient.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<LangVersion>latest</LangVersion>

<!-- Package metadata -->
<PackageId>Microsoft.Net.Remote.Client</PackageId>
<Version>0.5.2</Version>
<Authors>Microsoft</Authors>
<Company>Microsoft</Company>
<Product>NetRemote</Product>
<Description>NetRemote client library providing gRPC service bindings and protobuf definitions for remote network management operations.</Description>
<PackageTags>netremote;grpc;protobuf;network;wifi;remote</PackageTags>
<PackageProjectUrl>https://github.com/microsoft/netremote</PackageProjectUrl>
<RepositoryUrl>https://github.com/microsoft/netremote</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Copyright>Copyright (c) Microsoft Corporation. All rights reserved.</Copyright>

<!-- Build settings -->
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<!-- Output settings -->
<PackageOutputPath>$(MSBuildThisFileDirectory)../../out/nuget</PackageOutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.25.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.59.0" />
<PackageReference Include="Grpc.Tools" Version="2.59.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<!--
Proto files for code generation.
These are compiled at build time by Grpc.Tools using the Google.Protobuf and Grpc.Net.Client
versions specified above. The generated C# stubs are included in the final package DLL.

GrpcServices options:
- None: Generate only protobuf message types (no gRPC service client/server)
- Client: Generate protobuf messages + gRPC client stubs
- Server: Generate protobuf messages + gRPC server stubs
- Both: Generate protobuf messages + both client and server stubs
-->
<ItemGroup>
<Protobuf Include="../protos/NetworkCore.proto" GrpcServices="None">
<Link>Protos/NetworkCore.proto</Link>
</Protobuf>
<Protobuf Include="../protos/Network8021x.proto" GrpcServices="None">
<Link>Protos/Network8021x.proto</Link>
</Protobuf>
<Protobuf Include="../protos/WifiCore.proto" GrpcServices="None">
<Link>Protos/WifiCore.proto</Link>
</Protobuf>
<Protobuf Include="../protos/NetRemoteDataStream.proto" GrpcServices="None">
<Link>Protos/NetRemoteDataStream.proto</Link>
</Protobuf>
<Protobuf Include="../protos/NetRemoteDataStreamingService.proto" GrpcServices="Client">
<Link>Protos/NetRemoteDataStreamingService.proto</Link>
</Protobuf>
<Protobuf Include="../protos/NetRemoteNetwork.proto" GrpcServices="None">
<Link>Protos/NetRemoteNetwork.proto</Link>
</Protobuf>
<Protobuf Include="../protos/NetRemoteRfAttenuator.proto" GrpcServices="None">
<Link>Protos/NetRemoteRfAttenuator.proto</Link>
</Protobuf>
<Protobuf Include="../protos/NetRemoteRfAttenuatorService.proto" GrpcServices="Client">
<Link>Protos/NetRemoteRfAttenuatorService.proto</Link>
</Protobuf>
<Protobuf Include="../protos/NetRemoteService.proto" GrpcServices="Client">
<Link>Protos/NetRemoteService.proto</Link>
</Protobuf>
<Protobuf Include="../protos/NetRemoteWifi.proto" GrpcServices="None">
<Link>Protos/NetRemoteWifi.proto</Link>
</Protobuf>
</ItemGroup>

<!--
Include raw proto files in package for consumers who want to:
- Generate bindings for other languages
- Use custom code generation options
- Reference the proto definitions directly

PackagePath locations:
- contentFiles/any/any/Protos: Modern SDK-style projects (any language, any framework)
- content/Protos: Legacy packages.config projects
-->
<ItemGroup>
<None Include="../protos/*.proto" Pack="true" PackagePath="contentFiles/any/any/Protos;content/Protos" />
<None Include="README.md" Pack="true" PackagePath="/" />
</ItemGroup>

</Project>
73 changes: 73 additions & 0 deletions api/dotnet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Microsoft.Net.Remote.Client

A .NET client library for NetRemote, providing gRPC service bindings and Protocol Buffer definitions for remote network management operations.

## Overview

This package provides:

- **gRPC Client Stubs**: Pre-generated client stubs for all NetRemote services
- **Protocol Buffer Definitions**: Message types for network, Wi-Fi, and RF attenuator operations
- **Proto Files**: Raw `.proto` files included for use with other languages or custom code generation

## Installation

```bash
dotnet add package Microsoft.Net.Remote.Client
```

## Quick Start

```csharp
using Grpc.Net.Client;
using Microsoft.Net.Remote.Service;

// Create a channel to the NetRemote server
using var channel = GrpcChannel.ForAddress("http://localhost:5047");

// Create the client
var client = new NetRemote.NetRemoteClient(channel);

// Enumerate network interfaces
var response = await client.NetworkInterfacesEnumerateAsync(
new Microsoft.Net.Remote.Network.NetworkEnumerateInterfacesRequest());

foreach (var iface in response.Interfaces)
{
Console.WriteLine($"Interface: {iface.Id} ({iface.Kind})");
}
```

## Services

The package includes clients for the following services:

### NetRemote Service
Core network management operations including:
- Network interface enumeration
- Wi-Fi access point management (enable/disable, configuration)
- Wi-Fi authentication settings (including 802.1X)

### NetRemote Data Streaming Service
Real-time data streaming capabilities for network monitoring and diagnostics.

### NetRemote RF Attenuator Service
RF attenuator control for wireless testing scenarios.

## Proto Files

The raw `.proto` files are included in the package under the `Protos` content folder. These can be used to generate bindings for other languages or for custom code generation scenarios.

## Requirements

- .NET Core 3.0+ / .NET 5+ / .NET Standard 2.1 compatible runtime
- A running NetRemote server instance

## License

This project is licensed under the MIT License - see the [LICENSE](https://github.com/microsoft/netremote/blob/develop/LICENSE) file for details.

## Links

- [GitHub Repository](https://github.com/microsoft/netremote)
- [Documentation](https://github.com/microsoft/netremote#readme)
Loading
Loading