Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-5944 Removed NDesk.Options Library #14106

Merged
merged 24 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cb3e0ea
Removed NDesk.Options Library
JimmySanchezGlobant Jun 22, 2023
0f9174d
Merge branch 'DynamoDS:master' into DYN-5944
JimmySanchezGlobant Jun 23, 2023
4bb7b70
Removed Ndesk.Options from License and About Box
JimmySanchezGlobant Jun 23, 2023
d0b8b8d
Merge branch 'DynamoDS:master' into DYN-5944
JimmySanchezGlobant Jun 27, 2023
91fafcd
Fixed formatting and included CommandLine.dll
JimmySanchezGlobant Jun 27, 2023
2fb22c2
Moved references under .NET 4.8 ItemGroup
JimmySanchezGlobant Jun 27, 2023
61b2630
Moved more references under .NET 4.8 ItemGroup
JimmySanchezGlobant Jun 28, 2023
f1e6aec
Merge branch 'DynamoDS:master' into DYN-5944
JimmySanchezGlobant Jun 28, 2023
7cdc64c
Merge branch 'DynamoDS:master' into DYN-5944
JimmySanchezGlobant Jun 29, 2023
e855f59
Removed ILMerge and added dependencies directly to project
JimmySanchezGlobant Jun 29, 2023
324bb3e
Merge branch 'DYN-5944' of https://github.com/JimmySanchezGlobant/Dyn…
JimmySanchezGlobant Jun 29, 2023
fc1a09f
update
pinzart Jul 5, 2023
2e0af94
Merge branch 'DynamoDS:master' into DYN-5944
JimmySanchezGlobant Jul 5, 2023
33a1310
Update Md2Html.csproj
pinzart Jul 6, 2023
de6659d
Merge branch 'master' into pr/14106
pinzart Jul 6, 2023
4e5216a
Merge branch 'DYN-5944' of https://github.com/JimmySanchezGlobant/Dyn…
pinzart Jul 6, 2023
fc78c58
Update License.rtf
pinzart Jul 6, 2023
c819987
Update License.rtf
pinzart Jul 6, 2023
8e44108
Merge branch 'master' into pr/14106
pinzart Jul 12, 2023
ad9c4ef
Update License.rtf
pinzart Jul 12, 2023
2cf6b72
Merge branch 'master' into pr/14106
pinzart Jul 18, 2023
bda2f98
Update Md2Html.csproj
pinzart Jul 19, 2023
3d73767
Merge branch 'master' into pr/14106
pinzart Jul 19, 2023
4d6b5cb
Update License.rtf
pinzart Jul 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 6 additions & 25 deletions src/Tools/Md2Html/Md2Html.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ImportGroup Label="PropertySheets">
<Import Project="$(SolutionDir)Config\CS_SDK.props" />
</ImportGroup>
Expand All @@ -21,6 +21,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="HtmlSanitizer">
<Version>5.0.372</Version>
</PackageReference>
Expand All @@ -30,32 +31,12 @@
<PackageReference Include="Markdig">
<Version>0.22.0</Version>
</PackageReference>
<PackageReference Include="NDesk.Options">
<Version>0.2.1</Version>
</PackageReference>
</ItemGroup>
<Target Name="AfterBuildOps" AfterTargets="Build">
<Exec Condition=" '$([MSBuild]::IsOSPlatform(`Windows`))' == 'True'"
Command="if not exist $(SharedOutputPath) mkdir $(SharedOutputPath)"/>
<Exec Condition=" '$([MSBuild]::IsOSPlatform(`Windows`))' == 'True'" Command="if not exist $(SharedOutputPath) mkdir $(SharedOutputPath)" />
<!-- the ILMergePath property points to the location of ILMerge.exe console application -->
<Exec Condition=" '$([MSBuild]::IsOSPlatform(`Windows`))' == 'True'"
Command="$(ILMergeConsolePath) $(OutputPath)Md2Html.exe ^
/allowDup ^
/lib:$(OutputPath) ^
/out:$(SharedOutputPath)Md2Html.exe ^
AngleSharp.Css.dll ^
AngleSharp.dll ^
HtmlSanitizer.dll ^
Markdig.dll ^
NDesk.Options.dll ^
System.Buffers.dll ^
System.Memory.dll ^
System.Numerics.Vectors.dll ^
System.Runtime.CompilerServices.Unsafe.dll ^
System.Text.Encoding.CodePages.dll " />
<Exec Condition=" '!$([MSBuild]::IsOSPlatform(`Windows`))' == 'True' "
Command="mkdir -p $(SharedOutputPath)"/>
<Exec Condition=" '!$([MSBuild]::IsOSPlatform(`Windows`))' == 'True' "
Command="cp $(OutputPath)*.* $(SharedOutputPath)"/>
<Exec Condition=" '$([MSBuild]::IsOSPlatform(`Windows`))' == 'True'" Command="$(ILMergeConsolePath) $(OutputPath)Md2Html.exe ^&#xD;&#xA; /allowDup ^&#xD;&#xA; /lib:$(OutputPath) ^&#xD;&#xA; /out:$(SharedOutputPath)Md2Html.exe ^&#xD;&#xA; AngleSharp.Css.dll ^&#xD;&#xA; AngleSharp.dll ^&#xD;&#xA; HtmlSanitizer.dll ^&#xD;&#xA; Markdig.dll ^&#xD;&#xA; System.Buffers.dll ^&#xD;&#xA; System.Memory.dll ^&#xD;&#xA; System.Numerics.Vectors.dll ^&#xD;&#xA; System.Runtime.CompilerServices.Unsafe.dll ^&#xD;&#xA; System.Text.Encoding.CodePages.dll " />
JimmySanchezGlobant marked this conversation as resolved.
Show resolved Hide resolved
<Exec Condition=" '!$([MSBuild]::IsOSPlatform(`Windows`))' == 'True' " Command="mkdir -p $(SharedOutputPath)" />
<Exec Condition=" '!$([MSBuild]::IsOSPlatform(`Windows`))' == 'True' " Command="cp $(OutputPath)*.* $(SharedOutputPath)" />
JimmySanchezGlobant marked this conversation as resolved.
Show resolved Hide resolved
</Target>
</Project>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need this to run on net48 too. Please verify if the new way works for net48. If not you will have to bring back the old way with (ilmerge) under the net48 condition.

  1. Net6 : SelfContained + PublishSingleFile
  2. net48 - ilmerge (old way)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pinzart90 As I told you before, this was built it correctly on .NET 4.8 and also I built it on .NET 6, and there wasn't any error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JimmySanchezGlobant please see the comment above from the bin diff job - the exe is not being produced:
#14106 (comment), so even if there are no errors, something seems off.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JimmySanchezGlobant the new flags do not work for net48 target.
You need to use the old way (with ILMerge) for net48
And the new flags + Add a new publish target (the flags work on publish only I think)
ex

<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Build;Publish">
  

But this should be added only under net6 target somehow. Also SelfContained should be set to false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pinzart90 The old way with ILMerge is failing, when I build the project it's returning the error code (missing file), so, it's not clear to me how this can solve this issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ILMerge should only work under net48. If you try to build from master it still works right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pinzart90 Yes, it's working well under . Net 4.8 from the master branch, it's weird, yesterday I did exactly the same test and it was failing on the ILMerge command, so, I don't know what to do to solve this, to be honest, I'm still very confused.

27 changes: 19 additions & 8 deletions src/Tools/Md2Html/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
using System;
using System;
using System.IO;
using NDesk.Options;
using CommandLine;
using CommandLine.Text;

namespace Md2Html
{
internal class CMDLineOptions
{
[Option('h', "help", Required = false, HelpText = "Show help and exit")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pinzart90 ... two thoughts - I don't see that this PR updates any of the tests. I think that ndesk options and command line parser require setting flags differently... ie / vs - or --, I can't remember for certain.

Have you tried running the docs browser tests locally? Perhaps the markdown converter tool is never shutting down causing some kind of deadlock in the test runner etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjkkirschner good catch, the md2html tests do seem to hang locally. Hopefully it is the same cause on the build machine

public bool ShowHelp { get; set; }
}

static class Program
{
static void Main(string[] args)
Expand Down Expand Up @@ -82,15 +89,19 @@ static string GetData()
static bool CheckForHelp(string[] args)
{
bool help = false;
var options = new OptionSet()
{
{@"h|?|help", @"Show help and exit", v => help = v != null },
};
var parser = new Parser(options => {
options.IgnoreUnknownArguments = true; options.HelpWriter = Console.Out;
options.CaseSensitive = false;
});
var results = parser.ParseArguments<CMDLineOptions>(args);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guess it's also possible that this is somehow messing with Console.Out or modifying the input argument list so it never makes its way to the rest of the Main function?


help = results.MapResult((cmdArgs) => {
return cmdArgs.ShowHelp;
}, errs => false);

options.Parse(args);
if (help)
{
options.WriteOptionDescriptions(Console.Out);
Console.WriteLine(HelpText.AutoBuild(results, null, null).ToString());
DisplayHelp();
}

Expand Down
45 changes: 31 additions & 14 deletions src/Tools/SignDynamo/Program.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography.X509Certificates;

using CommandLine;
using CommandLine.Text;
using DynamoCrypto;
using NDesk.Options;

namespace SignDynamo
{
internal class CMDLineOptions
{
[Option('i', "installer", Required = false, HelpText = "The path to the installer to sign.")]
public string Installer { get; set; } = String.Empty;

[Option('h', "help", Required = false, HelpText = "Show this message and exit.")]
public bool ShowHelp { get; set; }
}

class Program
{
private static byte[] privateBlob = null;
Expand Down Expand Up @@ -51,22 +60,30 @@ static void Main(string[] args)
private static bool ParseArguments(IEnumerable<string> args)
{
var showHelp = false;

var p = new OptionSet
var parser = new Parser(options =>
{
{"i:|installer","The path to the installer to sign.", v=> installerPath = v},
{"h|help", "Show this message and exit.", v=> showHelp = v != null}
};

options.IgnoreUnknownArguments = true; options.HelpWriter = Console.Out;
options.CaseSensitive = false;
});
var notParsed = new List<string>();

const string helpMessage = "Try 'SignDynamo --help' for more information.";

ParserResult<CMDLineOptions> parserResult;
var lineOptions = new CMDLineOptions();
var errors = new List<Error>();

try
{
notParsed = p.Parse(args);
parserResult = Parser.Default.ParseArguments<CMDLineOptions>(args)
.WithParsed(o => lineOptions = o)
.WithNotParsed(e => errors = (List<Error>)e);

errors.ForEach(x => notParsed.Add(x.ToString()));
installerPath = lineOptions.Installer;
showHelp = lineOptions.ShowHelp;
}
catch (OptionException e)
catch (AggregateException e)
{
Console.WriteLine(e.Message);
Console.WriteLine(helpMessage);
Expand All @@ -81,7 +98,7 @@ private static bool ParseArguments(IEnumerable<string> args)

if (showHelp)
{
ShowHelp(p);
ShowHelp(parserResult);
return false;
}

Expand All @@ -100,13 +117,13 @@ private static bool ParseArguments(IEnumerable<string> args)
return true;
}

private static void ShowHelp(OptionSet p)
private static void ShowHelp(ParserResult<CMDLineOptions> results)
{
Console.WriteLine("Usage: SignDynamo [OPTIONS]");
Console.WriteLine("Generate a signature file for a dynamo installer.");
Console.WriteLine();
Console.WriteLine("Options:");
p.WriteOptionDescriptions(Console.Out);
Console.WriteLine(HelpText.AutoBuild(results, null, null).ToString());
}
}
}
2 changes: 1 addition & 1 deletion src/Tools/SignDynamo/SignDynamo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<OutputPath>bin\$(Configuration)\</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NDesk.Options" Version="0.2.1" />
<PackageReference Include="CommandLineParser" Version="2.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\DynamoCrypto\DynamoCrypto.csproj">
JimmySanchezGlobant marked this conversation as resolved.
Show resolved Hide resolved
Expand Down