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

DYN-5944 Removed NDesk.Options Library #14106

merged 24 commits into from
Jul 21, 2023

Conversation

JimmySanchezGlobant
Copy link
Contributor

Please Note:

  1. Before submitting the PR, please review How to Contribute to Dynamo
  2. Dynamo Team will meet 1x a month to review PRs found on Github (Issues will be handled separately)
  3. PRs will be reviewed from oldest to newest
  4. If a reviewed PR requires changes by the owner, the owner of the PR has 30 days to respond. If the PR has seen no activity by the next session, it will be either closed by the team or depending on its utility will be taken over by someone on the team
  5. PRs should use either Dynamo's default PR template or one of these other template options in order to be considered for review.
  6. PRs that do not have one of the Dynamo PR templates completely filled out with all declarations satisfied will not be reviewed by the Dynamo team.
  7. PRs made to the DynamoRevit repo will need to be cherry-picked into all the DynamoRevit Release branches that Dynamo supports. Contributors will be responsible for cherry-picking their reviewed commits to the other branches after a LGTM label is added to the PR.

Purpose

Remove NDesk.Options library and replace it with CommandLineParser library to unify all CLI programs.

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB

Release Notes

(FILL ME IN) Brief description of the fix / enhancement. Mandatory section

Reviewers

(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)

(FILL ME IN, optional) Any additional notes to reviewers or testers.

FYIs

(FILL ME IN, Optional) Names of anyone else you wish to be notified of

@mjkkirschner
Copy link
Member

@pinzart90 I've responded to your questions, let me know if you want to discuss further.

@mjkkirschner
Copy link
Member

mjkkirschner commented Jun 27, 2023

  1. ILMerge failure:
The command "C:\Users\svc_p_dynamobuild\.nuget\packages\ilmerge\3.0.41\build\..\tools\net452\ILMerge.exe bin\AnyCPU\Release\Md2Html.exe ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		/allowDup ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		/lib:bin\AnyCPU\Release\ ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		/out:E:\Builds\Dynamo_master\Dynamo\src\..\bin\AnyCPU\Release\Md2Html\Md2Html.exe ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		AngleSharp.Css.dll ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		AngleSharp.dll ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073:         CommandLine.dll ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		HtmlSanitizer.dll ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		Markdig.dll ^		
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		System.Buffers.dll ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		System.Memory.dll ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		System.Numerics.Vectors.dll ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		System.Runtime.CompilerServices.Unsafe.dll ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		System.Text.Encoding.CodePages.dll " exited with code 9009.

    392 Warning(s)
    1 Error(s)

potentially we remove this step for now and resolve in the other ILMerge update task.

@JimmySanchezGlobant do local builds work for net48 and net6? Do you see the same errors?

  1. I expect there to be test failures on this PR once parallel tests run.

  2. at least temporarily (2.19) I believe we'll need to add a copy of ndesk.options to the extern folder and copy it to the bin folder using the legacy_remove_me infrastructure.

@aparajit-pratap
Copy link
Contributor

  1. ILMerge failure:
The command "C:\Users\svc_p_dynamobuild\.nuget\packages\ilmerge\3.0.41\build\..\tools\net452\ILMerge.exe bin\AnyCPU\Release\Md2Html.exe ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		/allowDup ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		/lib:bin\AnyCPU\Release\ ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		/out:E:\Builds\Dynamo_master\Dynamo\src\..\bin\AnyCPU\Release\Md2Html\Md2Html.exe ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		AngleSharp.Css.dll ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		AngleSharp.dll ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073:         CommandLine.dll ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		HtmlSanitizer.dll ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		Markdig.dll ^		
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		System.Buffers.dll ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		System.Memory.dll ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		System.Numerics.Vectors.dll ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		System.Runtime.CompilerServices.Unsafe.dll ^
E:\Builds\Dynamo_master\Dynamo\src\Tools\Md2Html\Md2Html.csproj(43,9): error MSB3073: 		System.Text.Encoding.CodePages.dll " exited with code 9009.

    392 Warning(s)
    1 Error(s)

potentially we remove this step for now and resolve in the other ILMerge update task.

@JimmySanchezGlobant do local builds work for net48 and net6? Do you see the same errors?

  1. I expect there to be test failures on this PR once parallel tests run.
  2. at least temporarily (2.19) I believe we'll need to add a copy of ndesk.options to the extern folder and copy it to the bin folder using the legacy_remove_me infrastructure.

@mjkkirschner where are you seeing these errors, which job? Are these failing for .net6 or because of commandlineparser?

@mjkkirschner
Copy link
Member

@aparajit-pratap multiple builds - see the PR status checks, probably because of .net6 - but not sure.

@avidit avidit marked this pull request as draft June 28, 2023 00:55
@avidit avidit changed the title Removed NDesk.Options Library DYN-5944 Removed NDesk.Options Library Jun 28, 2023
@JimmySanchezGlobant
Copy link
Contributor Author

@JimmySanchezGlobant please try to build the md2html project without ilmerge. Try to add the dependencies directly to project and use <PublishSingleFile>true</PublishSingleFile> and <SelfContained>true</SelfContained> https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=cli

@pinzart90 Solved, it's building correctly, could you please review it again to know if anything is missing to do here?

@github-actions
Copy link

github-actions bot commented Jun 29, 2023

":white_check_mark: Bin-Diff Issue Resolved."
(Updated: 2023-07-05-13:56:39)

<Exec Condition=" '$([MSBuild]::IsOSPlatform(`Windows`))' == 'True'" Command="if not exist $(SharedOutputPath) mkdir $(SharedOutputPath)" />
<Exec Condition=" '!$([MSBuild]::IsOSPlatform(`Windows`))' == 'True' " Command="mkdir -p $(SharedOutputPath)" />
<Exec Condition=" '!$([MSBuild]::IsOSPlatform(`Windows`))' == 'True' " Command="cp $(OutputPath)*.* $(SharedOutputPath)" />
</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.

@pinzart90 pinzart90 marked this pull request as ready for review July 5, 2023 13:53
Copy link
Contributor

@sm6srw sm6srw left a comment

Choose a reason for hiding this comment

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

LGTM!

<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
Copy link
Member

Choose a reason for hiding this comment

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

why do we need direct references to these?

Copy link
Contributor

Choose a reason for hiding this comment

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

all these references need to be bundled in a single executable. From what I can tell, these dependencies were needed for net48 (when using ilmerge). I assume they are still needed on net6 (I did not check though)

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see. These are actually transitive dependencies from one of the other packageRefs.
I can remove these

@github-actions
Copy link

github-actions bot commented Jul 12, 2023

⚠️ [run-bin-diff-net60-windows] - Files Added/Deleted::1 new file(s) have been added
(Updated: 2023-07-21-13:05:43)

@pinzart90 pinzart90 marked this pull request as draft July 12, 2023 13:53
@@ -137,6 +137,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynamoSandbox", "DynamoSand
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssemblyRenamerCLI", "Tools\AssemblyRenamerCLI\AssemblyRenamerCLI.csproj", "{F382C3F8-C55C-4350-800A-3D13A94F8E13}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Md2Html", "Tools\Md2Html\Md2Html.csproj", "{0893F745-CB1A-427A-8E87-CA927273039A}"
Copy link
Member

Choose a reason for hiding this comment

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

@pinzart90 looks like a missing EndProject tag maybe messing up the build somehow?


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

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?

@pinzart90 pinzart90 marked this pull request as ready for review July 20, 2023 02:27
@pinzart90 pinzart90 merged commit ae24bb2 into DynamoDS:master Jul 21, 2023
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants