.NET 6.0 migration and accompanying test infra updates (#38)

* Runtime environment update to 6.0
* NET6 background service

Signed-off-by: Clemens Vasters <clemensv@microsoft.com>
This commit is contained in:
Clemens Vasters 2022-08-29 15:29:09 +02:00 коммит произвёл GitHub
Родитель 6f77bb1b1c
Коммит 57cfbd3d9c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
55 изменённых файлов: 1129 добавлений и 1420 удалений

122
.github/workflows/main-ci-build.yml поставляемый
Просмотреть файл

@ -1,61 +1,61 @@
name: Main and Release CI Build
on:
workflow_dispatch:
push:
branches: [ master, main ]
create:
tags:
- 'v*.*'
pull_request:
branches: [ master, main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build for Windows 10-x64
run: dotnet msbuild /t:Package /p:WindowsOnly=false /p:RuntimeIdentifier=win10-x64 /p:Configuration=Release /p:TargetFramework=netcoreapp5.0 /p:VersionSuffix=rel
- name: Build for Windows 10-arm64
run: dotnet msbuild /t:Restore,Package /p:WindowsOnly=false /p:RuntimeIdentifier=win10-arm /p:Configuration=Release /p:TargetFramework=netcoreapp5.0 /p:VersionSuffix=rel
- name: Build for Windows 10-x86
run: dotnet msbuild /t:Restore,Package /p:WindowsOnly=false /p:RuntimeIdentifier=win10-x86 /p:Configuration=Release /p:TargetFramework=netcoreapp5.0 /p:VersionSuffix=rel
- name: Build for macOS-x64
run: dotnet msbuild /t:Package /p:WindowsOnly=false /p:RuntimeIdentifier=osx-x64 /p:Configuration=Release /p:TargetFramework=netcoreapp5.0 /p:VersionSuffix=rel
- name: Build for Ubuntu 18-x64
run: dotnet msbuild /t:Package /p:WindowsOnly=false /p:RuntimeIdentifier=ubuntu.18.04-x64 /p:Configuration=Release /p:TargetFramework=netcoreapp5.0 /p:VersionSuffix=rel
- name: Build for Ubuntu 18-arm64
run: dotnet msbuild /t:Restore,Package /p:WindowsOnly=false /p:RuntimeIdentifier=ubuntu.18.04-arm64 /p:Configuration=Release /p:TargetFramework=netcoreapp5.0 /p:VersionSuffix=rel
- name: Build for Debian 10-x64
run: dotnet msbuild /t:Package /p:WindowsOnly=false /p:RuntimeIdentifier=debian.10-x64 /p:Configuration=Release /p:TargetFramework=netcoreapp5.0 /p:VersionSuffix=rel
- name: Test
run: dotnet test /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=ubuntu-x64 /p:Configuration=Debug
- uses: actions/upload-artifact@v2
with:
name: XBuild
path: artifacts/build/netcoreapp5.0
- name: Upload Binaries to the Release
uses: svenstaro/upload-release-action@v2
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/build/netcoreapp5.0/*
file_glob: true
tag: ${{ github.ref }}
overwrite: true
name: Main and Release CI Build
on:
workflow_dispatch:
push:
branches: [ master, main ]
create:
tags:
- 'v*.*'
pull_request:
branches: [ master, main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build for Windows 10-x64
run: dotnet msbuild /t:Package /p:WindowsOnly=false /p:RuntimeIdentifier=win10-x64 /p:Configuration=Release /p:TargetFramework=net6.0 /p:VersionSuffix=rel
- name: Build for Windows 10-arm64
run: dotnet msbuild /t:Restore,Package /p:WindowsOnly=false /p:RuntimeIdentifier=win10-arm /p:Configuration=Release /p:TargetFramework=net6.0 /p:VersionSuffix=rel
- name: Build for Windows 10-x86
run: dotnet msbuild /t:Restore,Package /p:WindowsOnly=false /p:RuntimeIdentifier=win10-x86 /p:Configuration=Release /p:TargetFramework=net6.0 /p:VersionSuffix=rel
- name: Build for macOS-x64
run: dotnet msbuild /t:Package /p:WindowsOnly=false /p:RuntimeIdentifier=osx-x64 /p:Configuration=Release /p:TargetFramework=net6.0 /p:VersionSuffix=rel
- name: Build for Ubuntu 20-x64
run: dotnet msbuild /t:Package /p:WindowsOnly=false /p:RuntimeIdentifier=ubuntu.20.04-x64 /p:Configuration=Release /p:TargetFramework=net6.0 /p:VersionSuffix=rel
- name: Build for Ubuntu 20-arm64
run: dotnet msbuild /t:Restore,Package /p:WindowsOnly=false /p:RuntimeIdentifier=ubuntu.20.04-arm64 /p:Configuration=Release /p:TargetFramework=net6.0 /p:VersionSuffix=rel
- name: Build for Debian 10-x64
run: dotnet msbuild /t:Package /p:WindowsOnly=false /p:RuntimeIdentifier=debian.10-x64 /p:Configuration=Release /p:TargetFramework=net6.0 /p:VersionSuffix=rel
- name: Test
run: dotnet test /p:TargetFramework=net6.0 /p:RuntimeIdentifier=ubuntu-x64 /p:Configuration=Debug
- uses: actions/upload-artifact@v2
with:
name: XBuild
path: artifacts/build/net6.0
- name: Upload Binaries to the Release
uses: svenstaro/upload-release-action@v2
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/build/net6.0/*
file_glob: true
tag: ${{ github.ref }}
overwrite: true

Просмотреть файл

@ -1,7 +1,6 @@
<Project>
<PropertyGroup>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp5.0' ">$(MicrosoftNETCoreAppPackageVersion)</RuntimeFrameworkVersion>
<NETStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netcoreapp5.0' ">$(NETStandardLibrary21PackageVersion)</NETStandardImplicitPackageVersion>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'net6.0' ">$(MicrosoftNETCoreAppPackageVersion)</RuntimeFrameworkVersion>
<!-- aspnet/BuildTools#662 Don't police what version of NetCoreApp we use -->
<NETCoreAppMaximumVersion>99.9</NETCoreAppMaximumVersion>
</PropertyGroup>
@ -9,4 +8,3 @@
<CallTarget Targets="VSTest" Condition="'$(IsTestProject)' == 'true'" />
</Target>
</Project>

Просмотреть файл

@ -1,12 +1,12 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0 as publish
FROM mcr.microsoft.com/dotnet/sdk:6.0 as publish
# ENV http_proxy=http://proxy.corporation.example:8080
# ENV https_proxy=http://proxy.corporation.example:8080
COPY . /azure-relay-bridge/
WORKDIR /azure-relay-bridge/src/azbridge
RUN dotnet publish azbridge.csproj -c Release -f netcoreapp5.0 -p:SelfContained=false -r ubuntu-x64 -p:PublishTrimmed=false -o /app
RUN dotnet publish azbridge.csproj -c Release -f net6.0 -p:SelfContained=false -r ubuntu-x64 -p:PublishTrimmed=false -o /app
FROM mcr.microsoft.com/dotnet/runtime:5.0
FROM mcr.microsoft.com/dotnet/runtime:6.0
RUN apt-get update
WORKDIR /app
COPY --from=publish /app .

Просмотреть файл

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29403.142
# Visual Studio Version 17
VisualStudioVersion = 17.3.32811.315
MinimumVisualStudioVersion = 15.0.26124.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Relay.Bridge", "src\Microsoft.Azure.Relay.Bridge\Microsoft.Azure.Relay.Bridge.csproj", "{864AE8D8-F770-499B-A9E2-46E07C8FD3D2}"
EndProject

Просмотреть файл

@ -5,7 +5,7 @@
"azbridge": {
"Exclusions": {
"DOC_MISSING": {
"lib/netcoreapp5.0/azbridge.dll": "no public API"
"lib/net6.0/azbridge.dll": "no public API"
}
}
}

Просмотреть файл

@ -1,57 +1,57 @@
# Azure Pipelines Build
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pr:
- master
variables:
BuildVersion.MajorMinor: 0.4
BuildVersion.Revision: $[counter(variables['Version.MajorMinor'], 0)]
BuildVersion: $(BuildVersion.MajorMinor).$(BuildVersion.Revision)
jobs:
- job: WindowsBuild
workspace:
clean: all
pool:
vmImage: 'windows-latest'
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
feedsToUse: 'select'
- task: MSBuild@1
inputs:
solution: '**/*.sln'
msbuildArguments: '/t:clean,package /p:WindowsOnly=true /p:Configuration=Release /p:VersionPrefix=$(BuildVersion) /p:VersionSuffix=rel'
- task: DotNetCoreCLI@2
inputs:
command: 'test'
arguments: '/p:WindowsOnly=true'
- publish: $(System.DefaultWorkingDirectory)\artifacts\build\net48
artifact: WindowsBuild
- job: LinuxBuild
workspace:
clean: all
pool:
vmImage: 'ubuntu-latest'
steps:
- task: ShellScript@2
inputs:
scriptPath: './package.sh'
arguments: '/p:VersionSuffix=rel'
- task: DotNetCoreCLI@2
inputs:
command: 'test'
arguments: '/p:RuntimeIdentifier=ubuntu-x64 /p:Configuration=Debug /p:TargetFramework=netcoreapp5.0'
- publish: $(System.DefaultWorkingDirectory)/artifacts/build/netcoreapp5.0
artifact: XBuild
# Azure Pipelines Build
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pr:
- master
variables:
BuildVersion.MajorMinor: 0.4
BuildVersion.Revision: $[counter(variables['Version.MajorMinor'], 0)]
BuildVersion: $(BuildVersion.MajorMinor).$(BuildVersion.Revision)
jobs:
- job: WindowsBuild
workspace:
clean: all
pool:
vmImage: 'windows-latest'
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
feedsToUse: 'select'
- task: MSBuild@1
inputs:
solution: '**/*.sln'
msbuildArguments: '/t:clean,package /p:WindowsOnly=true /p:Configuration=Release /p:VersionPrefix=$(BuildVersion) /p:VersionSuffix=rel'
- task: DotNetCoreCLI@2
inputs:
command: 'test'
arguments: '/p:WindowsOnly=true'
- publish: $(System.DefaultWorkingDirectory)\artifacts\build\net6.0
artifact: WindowsBuild
- job: LinuxBuild
workspace:
clean: all
pool:
vmImage: 'ubuntu-latest'
steps:
- task: ShellScript@2
inputs:
scriptPath: './package.sh'
arguments: '/p:VersionSuffix=rel'
- task: DotNetCoreCLI@2
inputs:
command: 'test'
arguments: '/p:RuntimeIdentifier=ubuntu-x64 /p:Configuration=Debug /p:TargetFramework=net6.0'
- publish: $(System.DefaultWorkingDirectory)/artifacts/build/net6.0
artifact: XBuild

Просмотреть файл

@ -3,35 +3,34 @@
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<PropertyGroup Label="Package Versions">
<PackagingTargetsPackageVersion>0.1.189</PackagingTargetsPackageVersion>
<PackagingTargetsPackageVersion>0.1.220</PackagingTargetsPackageVersion>
<WixPackageVersion>3.11.2</WixPackageVersion>
<MicrosoftDiagnosticsTracingEventSourcePackageVersion>1.1.28</MicrosoftDiagnosticsTracingEventSourcePackageVersion>
<MicrosoftDiagnosticsTracingTraceEventPackageVersion>2.0.66</MicrosoftDiagnosticsTracingTraceEventPackageVersion>
<MicrosoftNETCoreAppPackageVersion>5.0.0</MicrosoftNETCoreAppPackageVersion>
<MicrosoftNETCoreAppPackageVersion>6.0.0</MicrosoftNETCoreAppPackageVersion>
<MicrosoftNetHttpHeadersPackageVersion>2.2.8</MicrosoftNetHttpHeadersPackageVersion>
<MicrosoftNETTestSdkPackageVersion>16.9.4</MicrosoftNETTestSdkPackageVersion>
<NETStandardLibrary21PackageVersion>2.1.0</NETStandardLibrary21PackageVersion>
<MicrosoftNETTestSdkPackageVersion>17.3.0</MicrosoftNETTestSdkPackageVersion>
<SystemNetNetworkInformationPackageVersion>4.3.0</SystemNetNetworkInformationPackageVersion>
<SystemThreadingTasksDataflowPackageVersion>5.0.0</SystemThreadingTasksDataflowPackageVersion>
<SystemConsolePackageVersion>4.3.1</SystemConsolePackageVersion>
<SystemIOPackageVersion>4.3.0</SystemIOPackageVersion>
<SystemMemoryPackageVersion>4.5.4</SystemMemoryPackageVersion>
<SystemMemoryPackageVersion>4.5.5</SystemMemoryPackageVersion>
<SystemDiagnosticsTracingPackageVersion>4.3.0</SystemDiagnosticsTracingPackageVersion>
<SystemDiagnosticsDiagnosticSourcePackageVersion>4.6.0</SystemDiagnosticsDiagnosticSourcePackageVersion>
<SystemDiagnosticsDiagnosticSourcePackageVersion>6.0.0</SystemDiagnosticsDiagnosticSourcePackageVersion>
<SystemNetHttpPackageVersion>4.3.4</SystemNetHttpPackageVersion>
<SystemNetNameResolutionPackageVersion>4.3.0</SystemNetNameResolutionPackageVersion>
<YamlDotNetPackageVersion>11.1.0</YamlDotNetPackageVersion>
<MicrosoftExtensionsLoggingPackageVersion>3.0.0</MicrosoftExtensionsLoggingPackageVersion>
<MicrosoftExtensionsLoggingConsolePackageVersion>3.0.0</MicrosoftExtensionsLoggingConsolePackageVersion>
<XunitPackageVersion>2.4.1</XunitPackageVersion>
<YamlDotNetPackageVersion>12.0.0</YamlDotNetPackageVersion>
<MicrosoftExtensionsLoggingPackageVersion>6.0.0</MicrosoftExtensionsLoggingPackageVersion>
<MicrosoftExtensionsLoggingConsolePackageVersion>6.0.0</MicrosoftExtensionsLoggingConsolePackageVersion>
<XunitPackageVersion>2.4.2</XunitPackageVersion>
<NuGetVersioningVersion>5.9.0</NuGetVersioningVersion>
<DotnetXunitPackageVersion>2.3.1</DotnetXunitPackageVersion>
<XunitRunnerVisualStudioPackageVersion>2.4.3</XunitRunnerVisualStudioPackageVersion>
<XunitRunnerVisualStudioPackageVersion>2.4.5</XunitRunnerVisualStudioPackageVersion>
<XunitRunnerMsBuildPackageVersion>2.4.1</XunitRunnerMsBuildPackageVersion>
<NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
<MicrosoftAzureRelayPackageVersion>2.0.15596</MicrosoftAzureRelayPackageVersion>
<McMasterExtensionsCommandLineUtilsPackageVersion>3.1.0</McMasterExtensionsCommandLineUtilsPackageVersion>
<SerilogExtensionsLoggingFilePackageVersion>2.0.0</SerilogExtensionsLoggingFilePackageVersion>
<McMasterExtensionsCommandLineUtilsPackageVersion>4.0.1</McMasterExtensionsCommandLineUtilsPackageVersion>
<SerilogExtensionsLoggingFilePackageVersion>3.0.0</SerilogExtensionsLoggingFilePackageVersion>
</PropertyGroup>
<Import Project="$(DotNetPackageVersionPropsPath)" Condition=" '$(DotNetPackageVersionPropsPath)' != '' " />
</Project>

Просмотреть файл

@ -1,16 +1,17 @@
<Project>
<PropertyGroup>
<WindowsOnly>false</WindowsOnly>
<WindowsFrameworks Condition="'$(OS)'=='Windows_NT'">net48;</WindowsFrameworks>
<CoreFrameworks Condition="'$(WindowsOnly)'!='true'">netcoreapp5.0</CoreFrameworks>
<TargetFrameworks>$(WindowsFrameworks)$(CoreFrameworks)</TargetFrameworks>
<WindowsRuntimeIdentifiers Condition="'$(OS)'=='Windows_NT'">win7-x64;win7-x86;win10-x64;win10-x86;</WindowsRuntimeIdentifiers>
<UnixRuntimeIdentifiers Condition="'$(WindowsOnly)'=='false'">osx-x64;debian.9-x64;debian.10-x64;ubuntu.18.04-x64;ubuntu.18.04-arm64;ubuntu.20.04-x64;ubuntu.20.04-arm64;opensuse.15.0-x64;fedora.30-x64</UnixRuntimeIdentifiers>
<RuntimeIdentifiers>$(WindowsRuntimeIdentifiers)$(UnixRuntimeIdentifiers)</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<DotNetCoreRuntime Include="$(MicrosoftNETCoreAppPackageVersion)" />
</ItemGroup>
<PropertyGroup>
<WindowsOnly>false</WindowsOnly>
<CoreFrameworks>net6.0</CoreFrameworks>
<TargetFrameworks>$(CoreFrameworks)</TargetFrameworks>
<TargetFramework Condition="'$(TargetFramework)'==''">net6.0</TargetFramework>
<WindowsRuntimeIdentifiers Condition="'$(OS)'=='Windows_NT'">win7-x64;win7-x86;win10-x64;win10-x86;</WindowsRuntimeIdentifiers>
<UnixRuntimeIdentifiers Condition="'$(WindowsOnly)'=='false'">osx-x64;debian.9-x64;debian.10-x64;ubuntu.18.04-x64;ubuntu.18.04-arm64;ubuntu.20.04-x64;ubuntu.20.04-arm64;opensuse.15.0-x64;fedora.30-x64</UnixRuntimeIdentifiers>
<RuntimeIdentifiers>$(WindowsRuntimeIdentifiers)$(UnixRuntimeIdentifiers)</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="'$(OS)' == 'Windows_NT' OR $(RuntimeIdentifier.StartsWith('win'))">
<DefineConstants>_WINDOWS</DefineConstants>
</PropertyGroup>
<ItemGroup>
<DotNetCoreRuntime Include="$(MicrosoftNETCoreAppPackageVersion)" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,22 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

Просмотреть файл

@ -1,21 +1,21 @@
apiVersion: v2
name: foodportal2
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 1.16.0
apiVersion: v2
name: foodportal2
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 1.16.0

Просмотреть файл

@ -1,21 +1,21 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "foodportal2.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "foodportal2.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "foodportal2.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "foodportal2.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }}
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "foodportal2.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "foodportal2.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "foodportal2.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "foodportal2.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }}

Просмотреть файл

@ -1,63 +1,63 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "foodportal2.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "foodportal2.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "foodportal2.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common labels
*/}}
{{- define "foodportal2.labels" -}}
helm.sh/chart: {{ include "foodportal2.chart" . }}
{{ include "foodportal2.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Selector labels
*/}}
{{- define "foodportal2.selectorLabels" -}}
app.kubernetes.io/name: {{ include "foodportal2.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "foodportal2.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "foodportal2.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "foodportal2.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "foodportal2.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "foodportal2.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common labels
*/}}
{{- define "foodportal2.labels" -}}
helm.sh/chart: {{ include "foodportal2.chart" . }}
{{ include "foodportal2.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Selector labels
*/}}
{{- define "foodportal2.selectorLabels" -}}
app.kubernetes.io/name: {{ include "foodportal2.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "foodportal2.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "foodportal2.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

Просмотреть файл

@ -1,55 +1,55 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "foodportal2.fullname" . }}
labels:
{{- include "foodportal2.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "foodportal2.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "foodportal2.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "foodportal2.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "foodportal2.fullname" . }}
labels:
{{- include "foodportal2.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "foodportal2.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "foodportal2.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "foodportal2.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

Просмотреть файл

@ -1,41 +1,41 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "foodportal2.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "foodportal2.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "foodportal2.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "foodportal2.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}

Просмотреть файл

@ -1,15 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "foodportal2.fullname" . }}
labels:
{{- include "foodportal2.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "foodportal2.selectorLabels" . | nindent 4 }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "foodportal2.fullname" . }}
labels:
{{- include "foodportal2.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "foodportal2.selectorLabels" . | nindent 4 }}

Просмотреть файл

@ -1,8 +1,8 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "foodportal2.serviceAccountName" . }}
labels:
{{ include "foodportal2.labels" . | nindent 4 }}
{{- end -}}
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "foodportal2.serviceAccountName" . }}
labels:
{{ include "foodportal2.labels" . | nindent 4 }}
{{- end -}}

Просмотреть файл

@ -1,15 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "foodportal2.fullname" . }}-test-connection"
labels:
{{ include "foodportal2.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "foodportal2.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "foodportal2.fullname" . }}-test-connection"
labels:
{{ include "foodportal2.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "foodportal2.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never

Просмотреть файл

@ -1,66 +1,66 @@
# Default values for foodportal2.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: nginx
pullPolicy: IfNotPresent
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name:
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 80
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths: []
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}
# Default values for foodportal2.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: nginx
pullPolicy: IfNotPresent
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name:
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 80
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths: []
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}

Просмотреть файл

@ -7,7 +7,7 @@ if not errorlevel 0 (
)
echo *** Sanity check Windows
dotnet msbuild /t:restore /p:WindowsOnly=true
dotnet test -f net48 %*
dotnet test -f net6.0 %*
if not errorlevel 0 exit /b 1
echo *** Building and packaging Windows Targets
@ -16,20 +16,20 @@ if %_DOCKER_BUILD% == "true" (
dotnet msbuild /t:clean,restore,package /p:WindowsOnly=true;Configuration=Release;RuntimeIdentifier=win10-x64 %*
) else (
echo *** All platforms
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=true /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=win10-x64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=osx-x64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=debian.9-x64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=debian.10-x64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=ubuntu.18.04-x64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=ubuntu.18.04-arm64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=ubuntu.20.04-x64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=ubuntu.20.04-arm64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=opensuse.15.0-x64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=fedora.30-x64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=true /p:TargetFramework=net6.0 /p:RuntimeIdentifier=win10-x64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=osx-x64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=debian.9-x64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=debian.10-x64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=ubuntu.18.04-x64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=ubuntu.18.04-arm64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=ubuntu.20.04-x64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=ubuntu.20.04-arm64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=opensuse.15.0-x64 %*
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=fedora.30-x64 %*
)
if not errorlevel 0 exit /b 1
if %_DOCKER_BUILD% == "true" (
echo *** Building and packaging Unix/Linux Targets
docker run --rm -v %cd%:/build mcr.microsoft.com/dotnet/sdk:5.0 /build/package.sh %*
docker run --rm -v %cd%:/build mcr.microsoft.com/dotnet/sdk:6.0 /build/package.sh %*
)

Просмотреть файл

@ -3,14 +3,14 @@ pushd "${0%/*}" > /dev/null
if [ ! -z $APPVEYOR_BUILD_VERSION ]; then _VersionProp="/p:VersionPrefix=$APPVEYOR_BUILD_VERSION"; fi
if [ ! -z $BUILDVERSION ]; then _VersionProp="/p:VersionPrefix=$BUILDVERSION"; fi
dotnet restore
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=osx-x64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=debian.9-x64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=debian.10-x64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=ubuntu.18.04-x64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=ubuntu.18.04-arm64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=ubuntu.20.04-x64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=ubuntu.20.04-arm64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=opensuse.15.0-x64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=netcoreapp5.0 /p:RuntimeIdentifier=fedora.30-x64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=osx-x64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=debian.9-x64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=debian.10-x64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=ubuntu.18.04-x64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=ubuntu.18.04-arm64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=ubuntu.20.04-x64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=ubuntu.20.04-arm64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=opensuse.15.0-x64 $_BuildProp $_VersionProp $@
dotnet msbuild /t:Package /p:Configuration=Release /p:WindowsOnly=false /p:TargetFramework=net6.0 /p:RuntimeIdentifier=fedora.30-x64 $_BuildProp $_VersionProp $@
popd

Просмотреть файл

@ -14,7 +14,7 @@ namespace Microsoft.Azure.Relay.Bridge.Configuration
public class CommandLineSettings
{
#if NET48
#if _WINDOWS
[Option(CommandOptionType.NoValue, LongName = "svcinstall", ShortName = "I", Description = "Install as Windows Service")]
public bool? ServiceInstall { get; set; }
[Option(CommandOptionType.NoValue, LongName = "svcuninstall", ShortName = "U", Description = "Uninstall Windows Service")]

Просмотреть файл

@ -107,11 +107,7 @@ namespace Microsoft.Azure.Relay.Bridge.Configuration
set
{
var val = value != null ? value.Trim('\'', '\"') : value;
if (string.IsNullOrWhiteSpace(val))
{
RelayConnectionStringBuilder.Endpoint = new Uri("sb://undefined");
}
else
if (!string.IsNullOrWhiteSpace(val))
{
try
{
@ -150,8 +146,8 @@ namespace Microsoft.Azure.Relay.Bridge.Configuration
this);
}
}
}
RelayConnectionStringBuilder.SharedAccessKeyName = val;
RelayConnectionStringBuilder.SharedAccessKeyName = val;
}
}
}
@ -169,8 +165,8 @@ namespace Microsoft.Azure.Relay.Bridge.Configuration
if (val != null)
{
Convert.FromBase64String(val);
}
RelayConnectionStringBuilder.SharedAccessKey = val;
RelayConnectionStringBuilder.SharedAccessKey = val;
}
}
catch (FormatException e)
{
@ -193,7 +189,10 @@ namespace Microsoft.Azure.Relay.Bridge.Configuration
var val = value != null ? value.Trim('\'', '\"') : value;
try
{
RelayConnectionStringBuilder.SharedAccessSignature = val;
if (val != null)
{
RelayConnectionStringBuilder.SharedAccessSignature = val;
}
}
catch (ArgumentException e)
{
@ -346,9 +345,9 @@ namespace Microsoft.Azure.Relay.Bridge.Configuration
/// Specifies whether the client should terminate the
/// connection if it cannot set up all requested local, and remote port forwardings,
/// (e.g. if either end is unable to bind and listen on a specified port).
/// The default is false.
/// The default is true.
/// </summary>
public bool? ExitOnForwardFailure { get; set; }
public bool? ExitOnForwardFailure { get; set; } = true;
/// <summary>
/// Specifies whether remote hosts are allowed to connect to local
@ -887,7 +886,10 @@ namespace Microsoft.Azure.Relay.Bridge.Configuration
{
throw BridgeEventSource.Log.ArgumentNull(nameof(otherConfig));
}
if (otherConfig.AzureRelayConnectionString != null)
{
this.AzureRelayConnectionString = otherConfig.AzureRelayConnectionString;
}
if (otherConfig.AddressFamily != null)
{
this.AddressFamily = otherConfig.AddressFamily;

Просмотреть файл

@ -4,11 +4,7 @@
namespace Microsoft.Azure.Relay.Bridge
{
using System;
#if USE_MDT_EVENTSOURCE
using Microsoft.Diagnostics.Tracing;
#else
using System.Diagnostics.Tracing;
#endif
public class DiagnosticsRecord
{

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -7,7 +7,6 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);IncludeEtwManifest</TargetsForTfmSpecificBuildOutput>
<Description>Azure Relay Bridge</Description>
<IsPackable>false</IsPackable>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
@ -27,30 +26,6 @@
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="$(SystemDiagnosticsDiagnosticSourcePackageVersion)" />
</ItemGroup>
<Choose>
<When Condition="'$(TargetFramework)' == 'net48'">
<ItemGroup>
<PackageReference Include="Microsoft.Diagnostics.Tracing.EventSource" Version="$(MicrosoftDiagnosticsTracingEventSourcePackageVersion)" />
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="'$(TargetFramework)' == 'net48'">
<PropertyGroup>
<DefineConstants>$(DefineConstants);USE_MDT_EVENTSOURCE</DefineConstants>
</PropertyGroup>
</When>
</Choose>
<Target Name="IncludeEtwManifest" Condition="'$(TargetFramework)' == 'net48'">
<ItemGroup>
<TfmSpecificPackageFile Include="$(OutputPath)\*.etwManifest.dll" PackagePath="etw" />
<TfmSpecificPackageFile Include="$(OutputPath)\*.etwManifest.man" PackagePath="etw" />
</ItemGroup>
</Target>
<ItemGroup>
<Compile Update="Strings.Designer.cs">
<DesignTime>True</DesignTime>
@ -78,7 +53,7 @@
<Target Name="GetTargetPath" Returns="@(WixGetTargetPath)">
<ItemGroup>
<WixGetTargetPath Include="$(MSBuildProjectDirectory)\$(OutputPath)\net48\$(AssemblyName).dll" />
<WixGetTargetPath Include="$(MSBuildProjectDirectory)\$(OutputPath)\net6.0\$(AssemblyName).dll" />
</ItemGroup>
</Target>

Просмотреть файл

@ -60,7 +60,10 @@ namespace Microsoft.Azure.Relay.Bridge
public void Dispose()
{
this.IsOpen = false;
this.listener.CloseAsync(TimeSpan.FromSeconds(5)).GetAwaiter().GetResult();
if (this.listener != null)
{
this.listener.CloseAsync(TimeSpan.FromSeconds(5)).GetAwaiter().GetResult();
}
}
/// <summary>

Просмотреть файл

@ -53,14 +53,7 @@
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="etwManifest.dll">
<File Id="etwManifest.dll" KeyPath="yes" Source="$(var.Microsoft.Azure.Relay.Bridge.TargetDir)\Microsoft.Azure.Relay.Bridge.Microsoft-Azure-RelayBridge.etwManifest.dll" />
</Component>
<Component Id="etwManifest.man">
<File Id="etwManifest.man" KeyPath="yes" Source="$(var.Microsoft.Azure.Relay.Bridge.TargetDir)\Microsoft.Azure.Relay.Bridge.Microsoft-Azure-RelayBridge.etwManifest.man">
<util:EventManifest MessageFile="[etwManifest.dll]" ResourceFile="[etwManifest.dll]"></util:EventManifest>
</File>
</Component>
</ComponentGroup>
<ComponentGroup Id="PathInstall" Directory="INSTALLFOLDER">
<Component Id="Path" Guid="{bfc77cbe-3e65-4cb9-a1db-3d0b14bbe11f}" KeyPath="yes">

Просмотреть файл

@ -1 +1 @@
msbuild /t:publish /p:AlreadyPublished=true /p:TargetFramework=net48 /p:Platform=x64 /p:Configuration=Debug /p:RuntimeIdentifier=win10-x64
msbuild /t:publish /p:AlreadyPublished=true /p:TargetFramework=net6.0 /p:Platform=x64 /p:Configuration=Debug /p:RuntimeIdentifier=win10-x64

Просмотреть файл

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="WiX" version="3.11.2" targetFramework="net48" />
<package id="WiX" version="3.11.2" targetFramework="net6.0" />
</packages>

Просмотреть файл

@ -1,8 +1,8 @@
rem Check whether we are elevated and if not, restart the script elevated:
openfiles >nul 2>&1
if %ErrorLevel% neq 0 (
powershell.exe -Command "Start-Process cmd \"%*\" -Verb RunAs"
exit
)
echo "Hi there"
rem Check whether we are elevated and if not, restart the script elevated:
openfiles >nul 2>&1
if %ErrorLevel% neq 0 (
powershell.exe -Command "Start-Process cmd \"%*\" -Verb RunAs"
exit
)
echo "Hi there"

Просмотреть файл

@ -1,76 +0,0 @@
// // Copyright (c) Microsoft. All rights reserved.
// // Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Text;
#if NET48
namespace azbridge
{
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.ServiceProcess;
/// <summary>
/// Installer class for installing HybridConnectionManager as NT Service.
/// </summary>
[RunInstaller(true)]
public class RelayBridgeServiceInstaller : System.Configuration.Install.Installer
{
public const string ServiceName = "azbridgesvc";
public override void Install(System.Collections.IDictionary stateSaver)
{
this.Init();
base.Install(stateSaver);
}
public override void Uninstall(System.Collections.IDictionary savedState)
{
this.Init();
base.Uninstall(savedState);
}
[SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope",
Justification =
"serviceInstaller and processInstaller are used internally to install the service. They live for the duration of the installation."
)]
void Init()
{
var processInstaller = new ServiceProcessInstaller
{
Account = ServiceAccount.NetworkService
};
var serviceInstaller = new ServiceInstaller
{
StartType = ServiceStartMode.Automatic,
DelayedAutoStart = true,
ServiceName = RelayBridgeServiceInstaller.ServiceName,
DisplayName = RelayBridgeServiceInstaller.ServiceName,
};
Installers.Add(serviceInstaller);
Installers.Add(processInstaller);
}
protected override void OnBeforeInstall(System.Collections.IDictionary savedState)
{
//Get the existing assembly path parameter
StringBuilder path = new StringBuilder(Context.Parameters["assemblypath"]);
//Wrap the existing path in quotes if it isn't already
if (!path[0].Equals("\""))
{
path.Insert(0, "\"");
path.Append("\"");
}
//Add desired parameters
path.Append(" --svc");
//Set the new path
Context.Parameters["assemblypath"] = path.ToString();
}
}
}
#endif

Просмотреть файл

@ -9,11 +9,7 @@ namespace azbridge
using Microsoft.Azure.Relay.Bridge;
using Microsoft.Azure.Relay.Bridge.Configuration;
using System.Diagnostics;
#if USE_MDT_EVENTSOURCE
using Microsoft.Diagnostics.Tracing;
#else
using System.Diagnostics.Tracing;
#endif
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
@ -28,12 +24,6 @@ namespace azbridge
static void Main(string[] args)
{
// before we localize, make sure we have all the error
// messages in en-us
CultureInfo.CurrentUICulture =
CultureInfo.DefaultThreadCurrentUICulture =
CultureInfo.GetCultureInfoByIetfLanguageTag("en-us");
try
{
CommandLineSettings.Run(args, (c) => Run(c, args));
@ -52,7 +42,7 @@ namespace azbridge
{
try
{
#if NET48
#if _WINDOWS
if (settings.ServiceInstall.HasValue && settings.ServiceInstall.Value)
{
ServiceLauncher.InstallService();
@ -65,11 +55,10 @@ namespace azbridge
}
else if (settings.ServiceRun.HasValue && settings.ServiceRun.Value)
{
ServiceLauncher.Run(args);
ServiceLauncher.RunAsync(settings).GetAwaiter().GetResult();
return 0;
}
#endif
if ( !string.IsNullOrEmpty(settings.ConfigFile) && !File.Exists(settings.ConfigFile))
{
Console.WriteLine($"The config file was not found: {settings.ConfigFile}");
@ -143,7 +132,7 @@ namespace azbridge
}
logger = loggerFactory.CreateLogger("azbridge");
DiagnosticListener.AllListeners.Subscribe(new SubscriberObserver(logger));
Host host = new Host(config);
host.Start();

41
src/azbridge/RelayBridgeService.Designer.cs сгенерированный
Просмотреть файл

@ -1,41 +0,0 @@

#if NET48
namespace azbridge
{
partial class RelayBridgeService
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.ServiceName = "azbridgesvc";
}
#endregion
}
}
#endif

Просмотреть файл

@ -1,117 +1,88 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#if _WINDOWS
using Microsoft.Azure.Relay.Bridge.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Host = Microsoft.Azure.Relay.Bridge.Host;
#if NET48
namespace azbridge
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
#if USE_MDT_EVENTSOURCE
using Microsoft.Diagnostics.Tracing;
#else
using System.Diagnostics.Tracing;
#endif
using System.IO;
using System.ServiceProcess;
using System.Threading;
using Microsoft.Azure.Relay.Bridge;
using Microsoft.Azure.Relay.Bridge.Configuration;
using Microsoft.Extensions.Logging;
public partial class RelayBridgeService : ServiceBase
public class RelayBridgeService : BackgroundService
{
Host host;
ILogger logger = null;
private readonly Config settings;
private readonly ILogger _logger;
private Host host;
public RelayBridgeService()
public RelayBridgeService(Config settings, ILogger logger)
{
InitializeComponent();
}
public Host Host { get => host; }
protected override void OnStart(string[] args)
{
CommandLineSettings.Run(args, Run);
}
int Run(CommandLineSettings settings)
{
string svcConfigFileName =
(Environment.OSVersion.Platform == PlatformID.Unix) ?
$"/etc/azbridge/azbridge_config.svc.yml" :
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
$"Microsoft\\Azure Relay Bridge\\azbridge_config.svc.yml");
if (File.Exists(svcConfigFileName))
{
settings.ConfigFile = svcConfigFileName;
}
Config config = Config.LoadConfig(settings);
LogLevel logLevel = LogLevel.Error;
if (!settings.Quiet.HasValue || !settings.Quiet.Value)
{
if (config.LogLevel != null)
{
switch (config.LogLevel.ToUpper())
{
case "QUIET":
logLevel = LogLevel.None;
break;
case "FATAL":
logLevel = LogLevel.Critical;
break;
case "ERROR":
logLevel = LogLevel.Error;
break;
case "INFO":
logLevel = LogLevel.Information;
break;
case "VERBOSE":
logLevel = LogLevel.Trace;
break;
case "DEBUG":
case "DEBUG1":
case "DEBUG2":
case "DEBUG3":
logLevel = LogLevel.Debug;
break;
}
}
}
else
{
logLevel = LogLevel.None;
}
var loggerFactory = new LoggerFactory();
if ( !string.IsNullOrEmpty(config.LogFileName) )
{
loggerFactory.AddFile(config.LogFileName, logLevel);
}
logger = loggerFactory.CreateLogger("azbridge");
this.settings = settings;
_logger = logger;
DiagnosticListener.AllListeners.Subscribe(new SubscriberObserver(logger));
host = new Host(config);
host.Start();
return 0;
}
protected override void OnStop()
public RelayBridgeService(Config settings, ILogger<RelayBridgeService> logger):this(settings, (ILogger)logger)
{
}
public override Task StartAsync(CancellationToken cancellationToken)
{
try
{
host?.Stop();
if (host == null)
{
host = new Host(settings);
}
return base.StartAsync(cancellationToken);
}
finally
catch (System.Exception ex)
{
host = null;
_logger.LogError(ex, "{Message}", ex.Message);
Environment.Exit(1);
return Task.CompletedTask;
}
}
public override Task StopAsync(CancellationToken cancellationToken)
{
try
{
if (host != null)
{
host.Stop();
host = null;
}
return base.StopAsync(cancellationToken);
}
catch (System.Exception ex)
{
_logger.LogError(ex, "{Message}", ex.Message);
Environment.Exit(1);
return Task.CompletedTask;
}
}
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
try
{
if (host != null)
{
host.Start();
}
}
catch (System.Exception ex)
{
_logger.LogError(ex, "{Message}", ex.Message);
Environment.Exit(1);
}
return Task.CompletedTask;
}
}
}
#endif
#endif

Просмотреть файл

@ -1,37 +1,118 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#if NET48
#if _WINDOWS
namespace azbridge
{
using Microsoft.Azure.Relay.Bridge.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Configuration;
using Microsoft.Extensions.Logging.EventLog;
using System;
using System.Collections;
using System.Configuration;
using System.Configuration.Install;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.ServiceProcess;
using System.Threading;
using System.Threading.Tasks;
static class ServiceLauncher
{
const string ServiceName = "azbridgesvc";
const string ServiceName = "azbridgesvc";
const string DisplayName = "Azure Relay Bridge Service";
/// <summary>
/// The main entry point for the application.
/// </summary>
internal static void Run(string[] args)
internal static async Task RunAsync(CommandLineSettings settings)
{
var hcs = new RelayBridgeService();
string svcConfigFileName =
(Environment.OSVersion.Platform == PlatformID.Unix) ?
$"/etc/azbridge/azbridge_config.svc.yml" :
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
$"Microsoft\\Azure Relay Bridge\\azbridge_config.svc.yml");
if (IsInstalled())
if (File.Exists(svcConfigFileName))
{
ServiceBase[] servicesToRun = new ServiceBase[] { hcs };
ServiceBase.Run(servicesToRun);
settings.ConfigFile = svcConfigFileName;
}
else
{
Console.WriteLine(Strings.ServiceIsNotInstalled);
}
svcConfigFileName = Path.Combine(AppContext.BaseDirectory, "azbridge_config.svc.yml");
if (File.Exists(svcConfigFileName))
{
settings.ConfigFile = svcConfigFileName;
}
}
Config config = Config.LoadConfig(settings);
LogLevel logLevel = LogLevel.Error;
if (!settings.Quiet.HasValue || !settings.Quiet.Value)
{
if (config.LogLevel != null)
{
switch (config.LogLevel.ToUpper())
{
case "QUIET":
logLevel = LogLevel.None;
break;
case "FATAL":
logLevel = LogLevel.Critical;
break;
case "ERROR":
logLevel = LogLevel.Error;
break;
case "INFO":
logLevel = LogLevel.Information;
break;
case "VERBOSE":
logLevel = LogLevel.Trace;
break;
case "DEBUG":
case "DEBUG1":
case "DEBUG2":
case "DEBUG3":
logLevel = LogLevel.Debug;
break;
}
}
}
else
{
logLevel = LogLevel.None;
}
IHost host = Host.CreateDefaultBuilder()
.UseWindowsService(options =>
{
options.ServiceName = ServiceName;
})
.ConfigureServices(services =>
{
LoggerProviderOptions.RegisterProviderOptions<EventLogSettings, EventLogLoggerProvider>(services);
services.Configure<EventLogSettings>(settings =>
{
settings.SourceName = ServiceName;
});
services.AddSingleton(config);
services.AddHostedService<RelayBridgeService>();
})
.ConfigureLogging((context, logging) =>
{
logging.SetMinimumLevel(LogLevel.Debug);
if (!string.IsNullOrEmpty(config.LogFileName))
{
logging.AddFile(config.LogFileName, logLevel);
}
})
.Build();
await host.RunAsync();
}
/// <summary>
@ -41,42 +122,34 @@ namespace azbridge
{
if (IsInstalled())
return;
try
{
using (AssemblyInstaller installer = GetInstaller())
{
IDictionary state = new Hashtable();
try
{
installer.Install(state);
installer.Commit(state);
}
catch
{
try
{
installer.Rollback(state);
}
catch { }
throw;
}
}
}
catch
{
throw;
}
var filePath = Path.Combine(AppContext.BaseDirectory, "azbridge.exe");
ShellExecute(Environment.SystemDirectory + @"\sc.exe", "create \"" + ServiceName + "\" binPath= \"" + filePath + " -svc\" start= auto DisplayName= \"" + DisplayName + "\"");
}
internal static void UninstallService()
{
if (!IsInstalled())
return;
using (AssemblyInstaller installer = GetInstaller())
ShellExecute(Environment.SystemDirectory + @"\sc.exe", "delete \"" + ServiceName + "\"");
}
public static void ShellExecute(string command, string parameters)
{
var process = new Process
{
IDictionary state = new Hashtable();
installer.Uninstall(state);
StartInfo = new ProcessStartInfo(command, parameters)
{
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
}
};
process.Start();
process.WaitForExit();
if ( process.ExitCode != 0 )
{
throw new Exception($"Process failed with exit code {process.ExitCode}");
}
}
@ -84,7 +157,8 @@ namespace azbridge
{
if (!IsInstalled())
return;
#if _WINDOWS
#pragma warning disable CA1416 // Validate platform compatibility
using (ServiceController controller =
new ServiceController(ServiceName))
{
@ -95,10 +169,16 @@ namespace azbridge
TimeSpan.FromSeconds(10));
}
}
#pragma warning restore CA1416 // Validate platform compatibility
#else
return true;
#endif
}
internal static bool IsInstalled()
{
#if _WINDOWS
#pragma warning disable CA1416 // Validate platform compatibility
using (ServiceController controller = new ServiceController(ServiceName))
{
try
@ -111,27 +191,34 @@ namespace azbridge
}
return true;
}
#pragma warning restore CA1416 // Validate platform compatibility
#else
return true;
#endif
}
internal static bool IsRunning()
{
#if _WINDOWS
#pragma warning disable CA1416 // Validate platform compatibility
using (var controller = new ServiceController(ServiceName))
{
if (!IsInstalled())
return false;
return (controller.Status == ServiceControllerStatus.Running);
}
#pragma warning restore CA1416 // Validate platform compatibility
#else
return true;
#endif
}
internal static AssemblyInstaller GetInstaller()
{
AssemblyInstaller installer = new AssemblyInstaller(
typeof(RelayBridgeService).Assembly, null) {UseNewContext = true};
return installer;
}
internal static void StopService()
{
#if _WINDOWS
#pragma warning disable CA1416 // Validate platform compatibility
if (!IsInstalled())
return;
using (ServiceController controller =
@ -152,6 +239,8 @@ namespace azbridge
}
}
}
#pragma warning restore CA1416 // Validate platform compatibility
#endif
}
}
#endif

Просмотреть файл

@ -6,10 +6,7 @@ namespace azbridge
using System;
using System.Diagnostics;
using Microsoft.Extensions.Logging;
#if USE_MDT_EVENTSOURCE
#else
using System.Diagnostics.Tracing;
#endif
class SubscriberObserver : IObserver<DiagnosticListener>
{

Просмотреть файл

@ -5,11 +5,7 @@ namespace azbridge
{
using System;
using Microsoft.Azure.Relay.Bridge;
#if USE_MDT_EVENTSOURCE
using Microsoft.Diagnostics.Tracing;
#else
using System.Diagnostics.Tracing;
#endif
using System.Collections.Generic;
using Microsoft.Extensions.Logging;

Просмотреть файл

@ -0,0 +1,16 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
},
"EventLog": {
"SourceName": "azbridgesvc",
"LogName": "Application",
"LogLevel": {
"Microsoft": "Information",
"Microsoft.Hosting.Lifetime": "Information",
"azbridge.RelayBridgeService": "Information"
}
}
}
}

Просмотреть файл

@ -0,0 +1,16 @@
{
"Logging": {
"LogLevel": {
"Default": "Information"
},
"EventLog": {
"SourceName": "azbridgesvc",
"LogName": "Application",
"LogLevel": {
"Microsoft": "Information",
"Microsoft.Hosting.Lifetime": "Information",
"azbridge.RelayBridgeService": "Information"
}
}
}
}

Просмотреть файл

@ -1,13 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<DisableOutOfProcTaskHost>true</DisableOutOfProcTaskHost>
<PublishTrimmed>true</PublishTrimmed>
<PublishSingleFile>false</PublishSingleFile>
<OutputType>Exe</OutputType>
<DisableOutOfProcTaskHost>true</DisableOutOfProcTaskHost>
<SelfContained>true</SelfContained>
<PublishReadyToRunComposite>true</PublishReadyToRunComposite>
<PublishSingleFile Condition="'$(Configuration)' == 'Release'">true</PublishSingleFile>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">win10-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.Development.json" />
<None Remove="appsettings.json" />
</ItemGroup>
<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Globalization.Invariant" Value="true" />
</ItemGroup>
@ -27,11 +33,27 @@
<DebPriority>optional</DebPriority>
<DebSection>contrib/net</DebSection>
</PropertyGroup>
<Choose>
<When Condition="'$(OS)' == 'Windows_NT' OR $(RuntimeIdentifier.StartsWith('win'))">
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
</ItemGroup>
</When>
</Choose>
<ItemGroup>
<LinuxFolder Include="/var/log/azbridge" Group="azbridge" Owner="azbridge" RemoveOnUninstall="true" Condition="! $(RuntimeIdentifier.StartsWith('win'))" />
<LinuxFolder Include="/etc/azbridge" Group="azbridge" Owner="azbridge" RemoveOnUninstall="true" Condition="! $(RuntimeIdentifier.StartsWith('win'))" />
<Content Include="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="azbridge_config.svc.yml" CopyToPublishDirectory="PreserveNewest" Condition="! $(RuntimeIdentifier.StartsWith('win'))">
<LinuxPath>/etc/azbridge/azbridge_config.svc.yml</LinuxPath>
</Content>
@ -52,23 +74,6 @@
<PostRemoveScript>rm /usr/local/bin/azbridge</PostRemoveScript>
</PropertyGroup>
<Choose>
<When Condition="'$(TargetFramework)' == 'net48'">
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Net.Http" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml" />
</ItemGroup>
</When>
</Choose>
<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="$(McMasterExtensionsCommandLineUtilsPackageVersion)" />
<PackageReference Include="System.Console" Version="$(SystemConsolePackageVersion)" />
@ -88,24 +93,6 @@
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
<Choose>
<When Condition="'$(TargetFramework)' == 'net48'">
<ItemGroup>
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="$(MicrosoftDiagnosticsTracingTraceEventPackageVersion)" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.EventSource" Version="$(MicrosoftDiagnosticsTracingEventSourcePackageVersion)" />
<PackageReference Include="Wix" Version="$(WixPackageVersion)" />
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="'$(TargetFramework)' == 'net48'">
<PropertyGroup>
<DefineConstants>$(DefineConstants);USE_MDT_EVENTSOURCE</DefineConstants>
</PropertyGroup>
</When>
</Choose>
<ItemGroup>
<ProjectReference Include="..\Microsoft.Azure.Relay.Bridge\Microsoft.Azure.Relay.Bridge.csproj">
<Private>true</Private>
@ -139,7 +126,7 @@
<ItemGroup Condition="$(RuntimeIdentifier.StartsWith('debian')) OR $(RuntimeIdentifier.StartsWith('ubuntu')) OR $(RuntimeIdentifier.StartsWith('linuxmint'))">
<DebDependency Include="libcurl3 | libcurl4" Version="" />
<DebDependency Include="libssl1.0.0 | libssl1.0.2 | libssl1.1" Version="" />
<DebDependency Include="libgssapi-krb5-2"/>
<DebDependency Include="libgssapi-krb5-2" />
<DebDependency Include="zlib1g" Version="" />
<DebDependency Include="libicu52 | libicu55 | libicu57 | libicu60 | libicu62 | libicu63 | libicu66 | libicu67" Version="" />
</ItemGroup>
@ -176,27 +163,27 @@
<Target Name="GetTargetPath" Returns="@(WixGetTargetPath)">
<ItemGroup>
<WixGetTargetPath Include="$(MSBuildProjectDirectory)\$(OutputPath)\net48\$(AssemblyName).exe" />
<WixGetTargetPath Include="$(MSBuildProjectDirectory)\$(OutputPath)\net6.0\$(AssemblyName).exe" />
</ItemGroup>
</Target>
<Target Name="PackageZip" DependsOnTargets="CreateZip" Condition="$(RuntimeIdentifier.EndsWith($(PlatformTarget))) AND $(RuntimeIdentifier.StartsWith('win'))">
<Copy SourceFiles="$(ZipPath)" DestinationFolder="$(BuildDir)/$(TargetFramework)" />
</Target>
<Target Name="PackageTarball" DependsOnTargets="CreateTarball" Condition="('$(TargetFramework)' == 'netcoreapp5.0') AND $(UnixRuntimeIdentifiers.Contains($(RuntimeIdentifier)))">
<Target Name="PackageTarball" DependsOnTargets="CreateTarball" Condition="('$(TargetFramework)' == 'net6.0') AND $(UnixRuntimeIdentifiers.Contains($(RuntimeIdentifier)))">
<Copy SourceFiles="$(TarballPath)" DestinationFolder="$(BuildDir)/$(TargetFramework)" />
</Target>
<Target Name="PackageDebian" DependsOnTargets="CreateDeb" Condition="'$(OS)' == 'Unix' AND ('$(TargetFramework)' == 'netcoreapp5.0') AND ($(RuntimeIdentifier.StartsWith('ubuntu')) OR $(RuntimeIdentifier.StartsWith('debian')) OR $(RuntimeIdentifier.StartsWith('linuxmint')))">
<Target Name="PackageDebian" DependsOnTargets="CreateDeb" Condition="'$(OS)' == 'Unix' AND ('$(TargetFramework)' == 'net6.0') AND ($(RuntimeIdentifier.StartsWith('ubuntu')) OR $(RuntimeIdentifier.StartsWith('debian')) OR $(RuntimeIdentifier.StartsWith('linuxmint')))">
<Copy SourceFiles="$(DebPath)" DestinationFolder="$(BuildDir)/$(TargetFramework)" />
</Target>
<Target Name="PackageRpm" DependsOnTargets="CreateRpm" Condition="'$(OS)' == 'Unix' AND ('$(TargetFramework)' == 'netcoreapp5.0') AND ($(RuntimeIdentifier.StartsWith('rhel')) OR $(RuntimeIdentifier.StartsWith('centos')) OR $(RuntimeIdentifier.StartsWith('fedora')) OR $(RuntimeIdentifier.StartsWith('opensuse')) OR $(RuntimeIdentifier.StartsWith('ol')))">
<Target Name="PackageRpm" DependsOnTargets="CreateRpm" Condition="'$(OS)' == 'Unix' AND ('$(TargetFramework)' == 'net6.0') AND ($(RuntimeIdentifier.StartsWith('rhel')) OR $(RuntimeIdentifier.StartsWith('centos')) OR $(RuntimeIdentifier.StartsWith('fedora')) OR $(RuntimeIdentifier.StartsWith('opensuse')) OR $(RuntimeIdentifier.StartsWith('ol')))">
<Copy SourceFiles="$(RpmPath)" DestinationFolder="$(BuildDir)/$(TargetFramework)" />
</Target>
<Target Name="PackageWindows" DependsOnTargets="Publish" Condition="'$(OS)' == 'Windows_NT' AND '$(TargetFramework)' == 'net48' AND $(RuntimeIdentifier.StartsWith('win')) AND $(RuntimeIdentifier.EndsWith($(PlatformTarget)))">
<Target Name="PackageWindows" DependsOnTargets="Publish" Condition="'$(OS)' == 'Windows_NT' AND $(RuntimeIdentifier.StartsWith('win')) AND $(RuntimeIdentifier.EndsWith($(PlatformTarget)))">
<PropertyGroup>
<MsiDir>$(PublishDir)../msi</MsiDir>
<_OutputName>azbridge_installer.$(PackageVersion).$(RuntimeIdentifier)</_OutputName>
<VS160COMNTOOLS Condition="'$(VS160COMNTOOLS)'==''">C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\</VS160COMNTOOLS>
<VS160COMNTOOLS Condition="'$(VS160COMNTOOLS)'==''">C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\</VS160COMNTOOLS>
</PropertyGroup>
<Exec WorkingDirectory="../azbridge-installer" Command="restore.cmd" />
<!-- MUST USE 32-bit for WiX -->
@ -204,7 +191,7 @@
<Exec Command="&quot;$(VS160COMNTOOLS)..\..\MSBuild\Current\Bin\msbuild&quot; ../azbridge-installer/azbridge-installer.wixproj /t:Publish /p:TargetFramework=$(TargetFramework);RuntimeIdentifier=$(RuntimeIdentifier);BridgeProjectFile=$(MSBuildProjectFullPath);BridgePublishPath=$(MSBuildProjectDirectory)\$(PublishDir);OutputPath=$(MSBuildProjectDirectory)\$(MsiDir);OutputName=$(_OutputName);AlreadyPublished=true" />
<Copy SourceFiles="$(MSBuildProjectDirectory)\$(MsiDir)\$(_OutputName).msi" DestinationFolder="$(BuildDir)/$(TargetFramework)" />
</Target>
<Target Name="PackageOSX" DependsOnTargets="Publish" Condition="'$(OS)' == 'Unix' AND ('$(TargetFramework)' == 'netcoreapp5.0') AND ($(RuntimeIdentifier.StartsWith('osx')))">
<Target Name="PackageOSX" DependsOnTargets="Publish" Condition="'$(OS)' == 'Unix' AND ('$(TargetFramework)' == 'net6.0') AND ($(RuntimeIdentifier.StartsWith('osx')))">
</Target>
<Target Name="PublishPackages" DependsOnTargets="PackageDebian;PackageRpm;PackageWindows;PackageOSX;PackageZip;PackageTarball" Condition=" '$(RuntimeIdentifier)' != ''">
@ -218,7 +205,7 @@
</ItemGroup>
<MSBuild Projects="$(MSBuildProjectFile)" Targets="Package" Properties="TargetFramework=$(TargetFramework);RuntimeIdentifier=%(_PublishRuntimeIdentifier.Identity)" />
</Target>
<Target Name="PublishProjectForAllUnixRIDsIfTargetFrameworkSet" Condition=" '$(TargetFramework)' != '' and '$(TargetFramework)' != 'net48' and '$(RuntimeIdentifier)' == '' and ('$(OS)' == 'Unix' OR '$(WindowsOnly)'=='false')">
<Target Name="PublishProjectForAllUnixRIDsIfTargetFrameworkSet" Condition=" '$(TargetFramework)' != '' and '$(RuntimeIdentifier)' == '' and ('$(OS)' == 'Unix' OR '$(WindowsOnly)'=='false')">
<ItemGroup>
<_PublishRuntimeIdentifier Include="$(UnixRuntimeIdentifiers)" />
</ItemGroup>
@ -228,7 +215,7 @@
<ItemGroup>
<_PublishFramework Include="$(TargetFrameworks)" />
</ItemGroup>
<MSBuild Projects="$(MSBuildProjectFile)" Targets="Package" Properties="TargetFramework=%(_PublishFramework.Identity);RuntimeIdentifier=$(RuntimeIdentifier)" Condition="!('$(OS)' == 'Unix' AND '%(_PublishFramework.Identity)'=='net48')" />
<MSBuild Projects="$(MSBuildProjectFile)" Targets="Package" Properties="TargetFramework=%(_PublishFramework.Identity);RuntimeIdentifier=$(RuntimeIdentifier)" Condition="!('$(OS)' == 'Unix')" />
</Target>
<Target Name="Package" DependsOnTargets="PublishProjectIfFrameworkAndRIDSet;PublishProjectForAllFrameworksIfFrameworkUnset;PublishProjectForAllUnixRIDsIfTargetFrameworkSet;PublishProjectForAllWindowsRIDsIfTargetFrameworkSet" />
</Project>

Просмотреть файл

@ -93,6 +93,11 @@ LocalForward :
LogLevel : ERROR
# Name of the log file. Not used in Windows service mode when logging is directed to
# the Windows event log.
LogFileName :
# Specifies that a TCP port on the remote machine be bound to
# a name on the Azure Relay. Each entry can have four properties, "RelayName", "Host",
# "HostPort", and "LocalSocket".

Просмотреть файл

@ -1,6 +1,6 @@
FROM debian:stretch AS build
FROM debian:bullseye AS build
ARG package_name
COPY ./tmp/$package_name .
RUN apt-get update -y
RUN apt-get install -y ./$package_name mysql-client
RUN apt-get install -y ./$package_name default-mysql-client

Просмотреть файл

@ -1,8 +1,8 @@
FROM mysql:5 AS build
ARG package_name
COPY ./tmp/$package_name .
RUN apt-get update -y
RUN apt-get install -y ./$package_name
RUN mv /usr/local/bin/docker-entrypoint.sh /usr/local/bin/mysql-docker-entrypoint.sh
COPY docker-entrypoint.sh /usr/local/bin/
FROM mysql:5-debian AS build
ARG package_name
COPY ./tmp/$package_name .
RUN apt-get update -y
RUN apt-get install -y ./$package_name
RUN mv /usr/local/bin/docker-entrypoint.sh /usr/local/bin/mysql-docker-entrypoint.sh
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

Просмотреть файл

@ -1,78 +1,78 @@
rem @echo off
echo %~1 %~2 %~3 %~4 %~5 %~6
if not "%~1" == "" set Operation=%~1
if not "%~2" == "" set ImageName=%~2
if not "%~3" == "" set ImageSuffix=%~3
if not "%~4" == "" set VersionPrefix=%~4
if not "%~5" == "" set VersionSuffix=%~5
if not "%~6" == "" set TargetFramework=%~6
if "%Operation%"=="" set Operation=build
if "%ImageName%"=="" set ImageName=ubuntu.18.04-x64
if "%ImageSuffix%"=="" set ImageSuffix=deb
if "%VersionSuffix%"=="" set VersionSuffix=preview
if "%VersionPrefix%"=="" set VersionPrefix=1.0.0
if "%TargetFramework%"=="" set TargetFramework=netcoreapp5.0
set PackageName=azbridge.%VersionPrefix%-%VersionSuffix%.%ImageName%.%ImageSuffix%
pushd "%~dp0"
set _MOUNTPATH=%cd%
if "%Operation%"=="build" (
if NOT exist ..\..\artifacts\build\%TargetFramework%\%PackageName% (
echo Cannot find ..\..\artifacts\build\%TargetFramework%\%PackageName%
exit 2
)
if not exist "tmp" mkdir tmp
copy /y ..\..\artifacts\build\%TargetFramework%\%PackageName% tmp > NUL
docker build -f mysql.server.dockerfile . --tag azbridge-mysql-server --build-arg package_name=%PackageName%
docker build -f mysql.client.dockerfile . --tag azbridge-mysql-client --build-arg package_name=%PackageName%
rd /s /q tmp
popd
exit /b
)
if "%Operation%"=="test" (
goto test
)
if "%Operation%"=="clean" (
goto clean
)
else (
echo "Unknown operation"
)
exit
:test
if %AZBRIDGE_TEST_CXNSTRING% == "" (
echo AZBRIDGE_TEST_CXNSTRING environment variable must be set to valid relay connection string
exit /b
)
rem start the web server
docker run -v %_MOUNTPATH%:/tests -d -v %_MOUNTPATH%/my.cnf:/etc/mysqld/conf.d/my.cnf --rm -d -e AZBRIDGE_TEST_CXNSTRING=%AZBRIDGE_TEST_CXNSTRING% -e MYSQL_ROOT_PASSWORD=PaSsWoRd112233 -e MYSQL_PASSWORD=PaSsWoRd112233 -e MYSQL_USER=mysql azbridge-mysql-server:latest > srvrun.log
for /f %%i in ( srvrun.log ) do set _SERVER_NAME=%%i
rem run the client
ping -n 10 127.0.0.1 > NUL
docker run -v %_MOUNTPATH%:/tests -v %_MOUNTPATH%/my.cnf:/home/mysql/.my.cnf --rm -i -e AZBRIDGE_TEST_CXNSTRING=%AZBRIDGE_TEST_CXNSTRING% azbridge-mysql-client:latest bash /tests/run_client.sh
set RESULT=ERRORLEVEL
rem stop the web server
docker stop %_SERVER_NAME%
exit %RESULT%
:clean
set IMAGE_NAME=%ImageName%
for /f %%i in ('docker images %IMAGE_NAME% -q') do set _IMAGE_ID=%%i
if "%_IMAGE_ID%"=="" exit /b
docker rmi -f %IMAGE_NAME%:latest
exit
rem @echo off
echo %~1 %~2 %~3 %~4 %~5 %~6
if not "%~1" == "" set Operation=%~1
if not "%~2" == "" set ImageName=%~2
if not "%~3" == "" set ImageSuffix=%~3
if not "%~4" == "" set VersionPrefix=%~4
if not "%~5" == "" set VersionSuffix=%~5
if not "%~6" == "" set TargetFramework=%~6
if "%Operation%"=="" set Operation=build
if "%ImageName%"=="" set ImageName=ubuntu.18.04-x64
if "%ImageSuffix%"=="" set ImageSuffix=deb
if "%VersionSuffix%"=="" set VersionSuffix=preview
if "%VersionPrefix%"=="" set VersionPrefix=1.0.0
if "%TargetFramework%"=="" set TargetFramework=net6.0
set PackageName=azbridge.%VersionPrefix%-%VersionSuffix%.%ImageName%.%ImageSuffix%
pushd "%~dp0"
set _MOUNTPATH=%cd%
if "%Operation%"=="build" (
if NOT exist ..\..\artifacts\build\%TargetFramework%\%PackageName% (
echo Cannot find ..\..\artifacts\build\%TargetFramework%\%PackageName%
exit 2
)
if not exist "tmp" mkdir tmp
copy /y ..\..\artifacts\build\%TargetFramework%\%PackageName% tmp > NUL
docker build -f mysql.server.dockerfile . --tag azbridge-mysql-server --build-arg package_name=%PackageName%
docker build -f mysql.client.dockerfile . --tag azbridge-mysql-client --build-arg package_name=%PackageName%
rd /s /q tmp
popd
exit /b
)
if "%Operation%"=="test" (
goto test
)
if "%Operation%"=="clean" (
goto clean
)
else (
echo "Unknown operation"
)
exit
:test
if %AZBRIDGE_TEST_CXNSTRING% == "" (
echo AZBRIDGE_TEST_CXNSTRING environment variable must be set to valid relay connection string
exit /b
)
rem start the web server
docker run -v %_MOUNTPATH%:/tests -d -v %_MOUNTPATH%/my.cnf:/etc/mysqld/conf.d/my.cnf --rm -d -e AZBRIDGE_TEST_CXNSTRING=%AZBRIDGE_TEST_CXNSTRING% -e MYSQL_ROOT_PASSWORD=PaSsWoRd112233 -e MYSQL_PASSWORD=PaSsWoRd112233 -e MYSQL_USER=mysql azbridge-mysql-server:latest > srvrun.log
for /f %%i in ( srvrun.log ) do set _SERVER_NAME=%%i
rem run the client
ping -n 10 127.0.0.1 > NUL
docker run -v %_MOUNTPATH%:/tests -v %_MOUNTPATH%/my.cnf:/home/mysql/.my.cnf --rm -i -e AZBRIDGE_TEST_CXNSTRING=%AZBRIDGE_TEST_CXNSTRING% azbridge-mysql-client:latest bash /tests/run_client.sh
set RESULT=ERRORLEVEL
rem stop the web server
docker stop %_SERVER_NAME%
exit %RESULT%
:clean
set IMAGE_NAME=%ImageName%
for /f %%i in ('docker images %IMAGE_NAME% -q') do set _IMAGE_ID=%%i
if "%_IMAGE_ID%"=="" exit /b
docker rmi -f %IMAGE_NAME%:latest
exit

Просмотреть файл

@ -12,7 +12,7 @@ if [ -z ${ImageName+x} ]; then ImageName='ubuntu.18.04-x64'; fi
if [ -z ${ImageSuffix+x} ]; then VersionSuffix='deb'; fi
if [ -z ${VersionSuffix+x} ]; then VersionSuffix='preview'; fi
if [ -z ${VersionPrefix+x} ]; then VersionPrefix='1.0.0'; fi
if [ -z ${TargetFramework+x} ]; then TargetFramework='netcoreapp5.0'; fi
if [ -z ${TargetFramework+x} ]; then TargetFramework='net6.0'; fi
echo $@

Просмотреть файл

@ -1,90 +1,90 @@
rem @echo off
echo %~1 %~2 %~3 %~4 %~5 %~6
if not "%~1" == "" set Operation=%~1
if not "%~2" == "" set ImageName=%~2
if not "%~3" == "" set ImageSuffix=%~3
if not "%~4" == "" set VersionPrefix=%~4
if not "%~5" == "" set VersionSuffix=%~5
if not "%~6" == "" set TargetFramework=%~6
if "%Operation%"=="" set Operation=build
if "%ImageName%"=="" set ImageName=ubuntu.18.04-x64
if "%ImageSuffix%"=="" set ImageSuffix=deb
if "%VersionSuffix%"=="" set VersionSuffix=preview
if "%VersionPrefix%"=="" set VersionPrefix=1.0.0
if "%TargetFramework%"=="" set TargetFramework=netcoreapp5.0
pushd "%~dp0"
set PackageName=azbridge.%VersionPrefix%-%VersionSuffix%.%ImageName%.%ImageSuffix%
set _MOUNTPATH=%cd%
if "%Operation%"=="build" (
if NOT exist ..\..\artifacts\build\%TargetFramework%\%PackageName% (
echo Cannot find ..\..\artifacts\build\%TargetFramework%\%PackageName%
exit 2
)
if not exist "tmp" mkdir tmp
copy /y ..\..\artifacts\build\%TargetFramework%\%PackageName% tmp > NUL
docker build -f %ImageName%.server.dockerfile . --tag azbridge-nginx-server-%ImageName% --build-arg package_name=%PackageName%
docker build -f %ImageName%.client.dockerfile . --tag azbridge-nginx-client-%ImageName% --build-arg package_name=%PackageName%
rd /s /q tmp
popd
exit /b
)
if "%Operation%"=="test" (
goto test
)
if "%Operation%"=="clean" (
goto clean
)
else (
echo "Unknown operation"
popd
)
exit
:test
if '%AZBRIDGE_TEST_CXNSTRING%' == "" (
echo AZBRIDGE_TEST_CXNSTRING environment variable must be set to valid relay connection string
exit /b
)
rem start the web server
docker run -v %_MOUNTPATH%:/tests --rm -d -e AZBRIDGE_TEST_CXNSTRING=%AZBRIDGE_TEST_CXNSTRING% azbridge-nginx-server-%ImageName%:latest bash /tests/run_nginx.sh > srvrun.log
for /f %%i in ( srvrun.log ) do set _SERVER_NAME=%%i
rem run the client
docker run -v %_MOUNTPATH%:/tests --rm -e AZBRIDGE_TEST_CXNSTRING=%AZBRIDGE_TEST_CXNSTRING% azbridge-nginx-client-%ImageName%:latest bash /tests/run_client.sh
rem stop the web server
docker stop %_SERVER_NAME%
fc /L downloaded.txt index.html > NUL
if ERRORLEVEL 1 (
set _RESULT=%ERRORLEVEL%
echo Error %_RESULT%
)
if ERRORLEVEL 0 (
set _RESULT=0
echo OK
)
popd
exit _RESULT
:clean
set IMAGE_NAME=%ImageName%
for /f %%i in ('docker images azbridge-nginx-server-%IMAGE_NAME% -q') do set _IMAGE_ID=%%i
if "%_IMAGE_ID%"=="" exit /b
docker rmi -f azbridge-nginx-server-%ImageName%:latest
for /f %%i in ('docker images azbridge-nginx-client-%IMAGE_NAME% -q') do set _IMAGE_ID=%%i
if "%_IMAGE_ID%"=="" exit /b
docker rmi -f azbridge-nginx-client-%ImageName%:latest
popd
rem @echo off
echo %~1 %~2 %~3 %~4 %~5 %~6
if not "%~1" == "" set Operation=%~1
if not "%~2" == "" set ImageName=%~2
if not "%~3" == "" set ImageSuffix=%~3
if not "%~4" == "" set VersionPrefix=%~4
if not "%~5" == "" set VersionSuffix=%~5
if not "%~6" == "" set TargetFramework=%~6
if "%Operation%"=="" set Operation=build
if "%ImageName%"=="" set ImageName=ubuntu.18.04-x64
if "%ImageSuffix%"=="" set ImageSuffix=deb
if "%VersionSuffix%"=="" set VersionSuffix=preview
if "%VersionPrefix%"=="" set VersionPrefix=1.0.0
if "%TargetFramework%"=="" set TargetFramework=net6.0
pushd "%~dp0"
set PackageName=azbridge.%VersionPrefix%-%VersionSuffix%.%ImageName%.%ImageSuffix%
set _MOUNTPATH=%cd%
if "%Operation%"=="build" (
if NOT exist ..\..\artifacts\build\%TargetFramework%\%PackageName% (
echo Cannot find ..\..\artifacts\build\%TargetFramework%\%PackageName%
exit 2
)
if not exist "tmp" mkdir tmp
copy /y ..\..\artifacts\build\%TargetFramework%\%PackageName% tmp > NUL
docker build -f %ImageName%.server.dockerfile . --tag azbridge-nginx-server-%ImageName% --build-arg package_name=%PackageName%
docker build -f %ImageName%.client.dockerfile . --tag azbridge-nginx-client-%ImageName% --build-arg package_name=%PackageName%
rd /s /q tmp
popd
exit /b
)
if "%Operation%"=="test" (
goto test
)
if "%Operation%"=="clean" (
goto clean
)
else (
echo "Unknown operation"
popd
)
exit
:test
if '%AZBRIDGE_TEST_CXNSTRING%' == "" (
echo AZBRIDGE_TEST_CXNSTRING environment variable must be set to valid relay connection string
exit /b
)
rem start the web server
docker run -v %_MOUNTPATH%:/tests --rm -d -e AZBRIDGE_TEST_CXNSTRING=%AZBRIDGE_TEST_CXNSTRING% azbridge-nginx-server-%ImageName%:latest bash /tests/run_nginx.sh > srvrun.log
for /f %%i in ( srvrun.log ) do set _SERVER_NAME=%%i
rem run the client
docker run -v %_MOUNTPATH%:/tests --rm -e AZBRIDGE_TEST_CXNSTRING=%AZBRIDGE_TEST_CXNSTRING% azbridge-nginx-client-%ImageName%:latest bash /tests/run_client.sh
rem stop the web server
docker stop %_SERVER_NAME%
fc /L downloaded.txt index.html > NUL
if ERRORLEVEL 1 (
set _RESULT=%ERRORLEVEL%
echo Error %_RESULT%
)
if ERRORLEVEL 0 (
set _RESULT=0
echo OK
)
popd
exit _RESULT
:clean
set IMAGE_NAME=%ImageName%
for /f %%i in ('docker images azbridge-nginx-server-%IMAGE_NAME% -q') do set _IMAGE_ID=%%i
if "%_IMAGE_ID%"=="" exit /b
docker rmi -f azbridge-nginx-server-%ImageName%:latest
for /f %%i in ('docker images azbridge-nginx-client-%IMAGE_NAME% -q') do set _IMAGE_ID=%%i
if "%_IMAGE_ID%"=="" exit /b
docker rmi -f azbridge-nginx-client-%ImageName%:latest
popd

Просмотреть файл

@ -12,7 +12,7 @@ if [ -z ${ImageName+x} ]; then ImageName='ubuntu.18.04-x64'; fi
if [ -z ${ImageSuffix+x} ]; then VersionSuffix='deb'; fi
if [ -z ${VersionSuffix+x} ]; then VersionSuffix='preview'; fi
if [ -z ${VersionPrefix+x} ]; then VersionPrefix='1.0.0'; fi
if [ -z ${TargetFramework+x} ]; then TargetFramework='netcoreapp5.0'; fi
if [ -z ${TargetFramework+x} ]; then TargetFramework='net6.0'; fi
echo $@

Просмотреть файл

@ -2,15 +2,13 @@
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<DeveloperBuildTestTfms>netcoreapp5.0</DeveloperBuildTestTfms>
<DeveloperBuildTestTfms>net6.0</DeveloperBuildTestTfms>
<StandardTestTfms>$(DeveloperBuildTestTfms)</StandardTestTfms>
<StandardTestTfms Condition=" '$(DeveloperBuild)' != 'true' ">$(StandardTestTfms)</StandardTestTfms>
<StandardTestTfms Condition=" '$(DeveloperBuild)' != 'true' AND '$(OS)' == 'Windows_NT' ">$(StandardTestTfms);net461</StandardTestTfms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />
<PackageReference Condition="'$(OS)' == 'Windows_NT' AND '$(TargetFramework)' == 'net48'" Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
</ItemGroup>
</Project>

Просмотреть файл

@ -8,6 +8,7 @@ namespace Microsoft.Azure.Relay.Bridge.Test
using System.Net;
using System.Net.Sockets;
using Microsoft.Azure.Relay.Bridge.Configuration;
using Microsoft.Azure.Relay.Bridge.Tests;
using Xunit;
public class BridgeTest : IClassFixture<LaunchSettingsFixture>

Просмотреть файл

@ -8,6 +8,7 @@ namespace Microsoft.Azure.Relay.Bridge.Test
using System.Threading.Tasks;
using McMaster.Extensions.CommandLineUtils;
using Microsoft.Azure.Relay.Bridge.Configuration;
using Microsoft.Azure.Relay.Bridge.Tests;
using Xunit;
public class ConfigTest : IClassFixture<LaunchSettingsFixture>

Просмотреть файл

@ -6,7 +6,7 @@ using System.IO;
using System.Linq;
using System.Text;
namespace Microsoft.Azure.Relay.Bridge.Test
namespace Microsoft.Azure.Relay.Bridge.Tests
{
public class LaunchSettingsFixture : IDisposable
{

Просмотреть файл

@ -8,18 +8,11 @@
<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="$(McMasterExtensionsCommandLineUtilsPackageVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
<PackageReference Include="System.Net.Http" Version="$(SystemNetHttpPackageVersion)" />
<PackageReference Include="System.Memory" Version="$(SystemMemoryPackageVersion)" />
<PackageReference Include="System.Net.NameResolution" Version="$(SystemNetNameResolutionPackageVersion)" />
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="YamlDotNet" Version="$(YamlDotNetPackageVersion)" />
<!--<DotNetCliToolReference Include="dotnet-xunit" Version="$(DotnetXunitPackageVersion)" />-->
</ItemGroup>
<PropertyGroup>

Просмотреть файл

@ -3,7 +3,7 @@ pushd "%~dp0"
set xunitrunner=xunit.console.exe
where %xunitrunner% 2>&1
if ERRORLEVEL 1 set xunitrunner=C:\Tools\xUnit20\xunit.console.exe
"%xunitrunner%" "test\unit\Microsoft.Azure.Relay.Bridge.Tests\bin\Debug\net48\Microsoft.Azure.Relay.Bridge.Tests.dll" -appveyor
"%xunitrunner%" "test\unit\Microsoft.Azure.Relay.Bridge.Tests\bin\Debug\net6.0\Microsoft.Azure.Relay.Bridge.Tests.dll" -appveyor
rem cd test\nginx
rem msbuild /t:clean,build,vstest

Просмотреть файл

@ -4,12 +4,12 @@ if [ ! -z $APPVEYOR_BUILD_VERSION ]; then _VersionProp="/p:VersionPrefix=$APPVEY
dotnet test --verbosity=normal /p:SelfContained=false
pushd test/mysql
dotnet clean --verbosity=normal /p:Configuration=Debug /p:TargetFramework=netcoreapp5.0 $_BuildProp $_VersionProp $@
dotnet msbuild /t:build /p:Configuration=Debug /p:TargetFramework=netcoreapp5.0 $_BuildProp $_VersionProp $@
dotnet test --verbosity=normal /p:Configuration=Debug /p:TargetFramework=netcoreapp5.0 $_BuildProp $_VersionProp $@
dotnet clean --verbosity=normal /p:Configuration=Debug /p:TargetFramework=net6.0 $_BuildProp $_VersionProp $@
dotnet msbuild /t:build /p:Configuration=Debug /p:TargetFramework=net6.0 $_BuildProp $_VersionProp $@
dotnet test --verbosity=normal /p:Configuration=Debug /p:TargetFramework=net6.0 $_BuildProp $_VersionProp $@
popd
pushd test/nginx
dotnet clean --verbosity=normal /p:Configuration=Debug /p:TargetFramework=netcoreapp5.0 $_BuildProp $_VersionProp $@
dotnet msbuild /t:build /p:Configuration=Debug /p:TargetFramework=netcoreapp5.0 $_BuildProp $_VersionProp $@
dotnet test --verbosity=normal /p:Configuration=Debug /p:TargetFramework=netcoreapp5.0 $_BuildProp $_VersionProp $@
dotnet clean --verbosity=normal /p:Configuration=Debug /p:TargetFramework=net6.0 $_BuildProp $_VersionProp $@
dotnet msbuild /t:build /p:Configuration=Debug /p:TargetFramework=net6.0 $_BuildProp $_VersionProp $@
dotnet test --verbosity=normal /p:Configuration=Debug /p:TargetFramework=net6.0 $_BuildProp $_VersionProp $@
popd

Просмотреть файл

@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>0.3.0</VersionPrefix>
<VersionPrefix>0.4.0</VersionPrefix>
<VersionSuffix>rtm</VersionSuffix>
</PropertyGroup>
</Project>