Skip to content

Commit

Permalink
fix samples when running vs 1.+. update readme and project for spec d…
Browse files Browse the repository at this point in the history
…l. handle dotnet run better
  • Loading branch information
dovholuknf committed Apr 19, 2024
1 parent 2252f5b commit 243cb0f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion OpenZiti.Management/OpenZiti.Management.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<Target Name="DownloadMgmtYaml" BeforeTargets="Never">
<Exec Command="pwsh -Command iwr https://get.openziti.io/spec/management.yml -OutFile ./mgmt.yml" />
<Exec Command="pwsh -Command iwr $(ManagementSpecUrl) -OutFile ./management.yml -SkipCertificateCheck" />
</Target>
<ItemGroup>
<None Remove="management.yml" />
Expand Down
4 changes: 3 additions & 1 deletion OpenZiti.Management/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

This project exists as a C# implementation of the OpenZiti management API spec. Open the .csproj to see how it works.
It basically runs a powershell command to pull down the spec from a predefined url, caching it. You can run that
msbuild target with something like `dotnet build /t:DownloadMgmtYaml` to refresh the spec.
msbuild target with something like
`dotnet build /t:DownloadMgmtYaml /p:ManagementSpecUrl=https://localhost:1280/edge/management/v1/specs/edge-management/spec`
to refresh the spec. Replace the url with the expected url.

1 change: 1 addition & 0 deletions OpenZiti.Management/management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13920,6 +13920,7 @@ definitions:
enum:
- Dial
- Bind
- Invalid
dialBindArray:
type: array
items:
Expand Down
11 changes: 10 additions & 1 deletion OpenZiti.NET.Samples/src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.

using OpenZiti.Debugging;
using System;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using MLog = Microsoft.Extensions.Logging;
Expand All @@ -30,7 +31,7 @@ private static async Task Main(string[] args) {
//try { Console.Clear(); } catch (Exception) { /*ignore exceptions*/ }
LoggingHelper.LogToConsole(MLog.LogLevel.Trace);
API.NativeLogger = API.DefaultNativeLogFunction;

var currentAssembly = Assembly.GetExecutingAssembly();
if (args == null || args.Length < 1) {
Console.WriteLine("These samples expect a parameter indicating which sample to run.");
Expand All @@ -47,6 +48,14 @@ private static async Task Main(string[] args) {
return;
}

if ( args[0].Contains(AppDomain.CurrentDomain.FriendlyName )) {
Console.WriteLine("args[0] contains the AppDomain.CurrentDomain.FriendlyName, must be using dotnet run: ");
Array.ForEach(args, Console.WriteLine);
args = args.Skip(1).ToArray();
} else {
Console.WriteLine(AppDomain.CurrentDomain.FriendlyName);
}

if (args.Length > 1) {
SampleSetup.Initialize = (args[1]?.ToLower().Trim() != "noinit");
if (args.Length > 2) {
Expand Down

0 comments on commit 243cb0f

Please sign in to comment.