diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4977da5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,40 @@ +name: Build + +on: + push: + branches: [main, releases/**] + pull_request: + branches: [main, releases/**] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + build: + name: Build on Windows + runs-on: windows-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' + - name: Build examples + run: dotnet build examples/Examples.slnx + + - name: Check formatting (examples) + if: always() + run: dotnet format examples/Examples.slnx --verify-no-changes + + - name: Build metadata-builder + if: always() + run: dotnet build metadata-builder/MetadataBuilder.slnx + + - name: Check formatting (metadata-builder) + if: always() + run: dotnet format metadata-builder/MetadataBuilder.slnx --verify-no-changes diff --git a/README.md b/README.md index 30678e7..dacbc3a 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,14 @@ # Datastore .NET Examples -This repo contains the source code for examples that show how to use the .NET API of NI Measurement Data Services. -These examples do not go through any build process, you can simply copy them to a system that has the necessary -software installed. +This repo contains the source code for examples that show how to use the .NET API of NI Measurement Data Services. These examples do not go through any build process, you can simply copy them to a system that has the necessary software installed. ## Running the Examples 1. Clone or download this repository. -2. Copy the contents of `Examples` to a system that has NI Measurement Data Services and the .NET framework installed. +2. Copy the contents of `examples` to a system that has NI Measurement Data Services including .NET installed. 3. Compile and run the console applications defined in the .csproj files in the `Examples` directory. -4. Be aware that running these examples will publish data to the default datastore location on your system. Data that is -published by a certain example may show up in queries from other examples or from your own Measurement Data Services application. +4. Running these examples will publish data to the `examples/temp_data` folder in the repo. ## Installation -As a prerequisite to using the DataStore .NET API, you must install Measurement Data Services -Software 2026 Q1 or later on your system. You can download and install this software using -[NI Package Manager](https://www.ni.com/en/support/downloads/software-products/download.package-manager.html). \ No newline at end of file +As a prerequisite to using the DataStore .NET API, you must install Measurement Data Services Software 2026 Q1 or later on your system. You can download and install this software using [NI Package Manager](https://www.ni.com/en/support/downloads/software-products/download.package-manager.html). diff --git a/examples/DataStoreContext/DataStoreContext.cs b/examples/DataStoreContext/DataStoreContext.cs index 6d82b98..6e4a256 100644 --- a/examples/DataStoreContext/DataStoreContext.cs +++ b/examples/DataStoreContext/DataStoreContext.cs @@ -16,7 +16,7 @@ public class DataStoreContext : IDisposable private const string DataStoreIngestDirectoryPathEnvVar = "NIDATASTORE_DATASTORESETTINGS__INGESTDIRECTORY"; private const string DataStoreFailedIngestDirectoryPathEnvVar = "NIDATASTORE_DATASTORESETTINGS__FAILEDINGESTDIRECTORY"; private const string DataStoreTdmsExpirationSecondsEnvName = "NIDATASTORE_DATASTORESETTINGS__TDMSFILECACHEEXPIRATIONSECONDS"; - + private const string DefaultFolderName = "temp_data"; private readonly string? _baseDirectoryPath; @@ -112,12 +112,12 @@ private string GetBaseDirectoryHash() { string baseDirectoryPath = GetBaseDirectoryPath(); string resolvedPath = Path.GetFullPath(baseDirectoryPath); - + using (var sha256 = SHA256.Create()) { byte[] pathBytes = Encoding.UTF8.GetBytes(resolvedPath); byte[] hashBytes = sha256.ComputeHash(pathBytes); - + // Convert to hex string and take first 32 characters StringBuilder sb = new StringBuilder(); for (int i = 0; i < Math.Min(16, hashBytes.Length); i++) diff --git a/examples/Directory.Packages.props b/examples/Directory.Packages.props index cd4d716..96983a4 100644 --- a/examples/Directory.Packages.props +++ b/examples/Directory.Packages.props @@ -6,7 +6,7 @@ - + \ No newline at end of file diff --git a/examples/Extension Attributes/Extension Attributes.cs b/examples/Extension Attributes/Extension Attributes.cs index 70890f1..c6d7b3c 100644 --- a/examples/Extension Attributes/Extension Attributes.cs +++ b/examples/Extension Attributes/Extension Attributes.cs @@ -1,5 +1,5 @@ using NationalInstruments; -using NationalInstruments.DataStore.Utilities; +using NationalInstruments.DataStore.Utilities; using NationalInstruments.MeasurementLink.Discovery.V1; using NationalInstruments.Measurements.Data.V1; using NationalInstruments.Measurements.Metadata.V1; diff --git a/metadata-builder/Directory.Packages.props b/metadata-builder/Directory.Packages.props index 70b028b..9855072 100644 --- a/metadata-builder/Directory.Packages.props +++ b/metadata-builder/Directory.Packages.props @@ -5,8 +5,8 @@ - - + + \ No newline at end of file diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000..e11e96e --- /dev/null +++ b/nuget.config @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file