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 13 commits
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
8 changes: 0 additions & 8 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ Copyright © 2021 Alexe Zimarev

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Ndesk.Options v.0.2.1.0:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

System.Collections.Immutable v.1.4.0:
Copyright (c) 2017 .NET Foundation and Contributors
All rights reserved.
Expand Down
3,213 changes: 1,392 additions & 1,821 deletions doc/distrib/License.rtf

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/Dynamo.All.Net6.sln
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ 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?

EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|NET60_Windows = Debug|NET60_Windows
Expand Down Expand Up @@ -330,6 +332,10 @@ Global
{F382C3F8-C55C-4350-800A-3D13A94F8E13}.Debug|NET60_Windows.ActiveCfg = Debug|NET60_Windows
{F382C3F8-C55C-4350-800A-3D13A94F8E13}.Debug|NET60_Windows.Build.0 = Debug|NET60_Windows
{F382C3F8-C55C-4350-800A-3D13A94F8E13}.Release|NET60_Windows.ActiveCfg = Release|NET60_Windows
{0893F745-CB1A-427A-8E87-CA927273039A}.Debug|NET60_Windows.ActiveCfg = Debug|NET60_Windows
{0893F745-CB1A-427A-8E87-CA927273039A}.Debug|NET60_Windows.Build.0 = Debug|NET60_Windows
{0893F745-CB1A-427A-8E87-CA927273039A}.Release|NET60_Windows.ActiveCfg = Release|NET60_Windows
{0893F745-CB1A-427A-8E87-CA927273039A}.Release|NET60_Windows.Build.0 = Release|NET60_Windows
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -376,6 +382,7 @@ Global
{4C2AEACC-617D-4B90-ADCD-FE294A43A68F} = {2C6A6573-28B0-4239-BD33-6AECCD25106C}
{0DD3E4ED-66AA-47FC-9EB9-2A0E6A0EA01B} = {D114C59C-CF66-4CC2-980F-9301FB4EA4E1}
{F382C3F8-C55C-4350-800A-3D13A94F8E13} = {D114C59C-CF66-4CC2-980F-9301FB4EA4E1}
{0893F745-CB1A-427A-8E87-CA927273039A} = {D114C59C-CF66-4CC2-980F-9301FB4EA4E1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {89CB19C6-BF0A-4E6A-BFDA-79D143EAB59D}
Expand Down
107 changes: 59 additions & 48 deletions src/Tools/Md2Html/Md2Html.csproj
Original file line number Diff line number Diff line change
@@ -1,61 +1,72 @@
<Project Sdk="Microsoft.NET.Sdk">
<ImportGroup Label="PropertySheets">
<Import Project="$(SolutionDir)Config\CS_SDK.props" />
</ImportGroup>
<PropertyGroup>
<ProjectGuid>{0893F745-CB1A-427A-8E87-CA927273039A}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Md2Html</RootNamespace>
<AssemblyName>Md2Html</AssemblyName>
<SharedOutputPath>$(OutputPath)\Md2Html\</SharedOutputPath>
<OutputPath>bin\AnyCPU\$(Configuration)\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="HtmlSanitizer">
<Version>5.0.372</Version>
</PackageReference>
<PackageReference Include="ILMerge">
<Version>3.0.41</Version>
</PackageReference>
<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)"/>
<!-- the ILMergePath property points to the location of ILMerge.exe console application -->
<Exec Condition=" '$([MSBuild]::IsOSPlatform(`Windows`))' == 'True'"
Command="$(ILMergeConsolePath) $(OutputPath)Md2Html.exe ^
<Project Sdk="Microsoft.NET.Sdk">
<ImportGroup Label="PropertySheets">
<Import Project="$(SolutionDir)Config\CS_SDK.props" />
</ImportGroup>
<PropertyGroup>
<ProjectGuid>{0893F745-CB1A-427A-8E87-CA927273039A}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Md2Html</RootNamespace>
<AssemblyName>Md2Html</AssemblyName>
<SharedOutputPath>$(OutputPath)\Md2Html\</SharedOutputPath>
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>false</SelfContained>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
JimmySanchezGlobant marked this conversation as resolved.
Show resolved Hide resolved
</ItemGroup>
<ItemGroup>
<PackageReference Include="AngleSharp" Version="0.14.0" />
<PackageReference Include="AngleSharp.Css" Version="0.14.2" />
<PackageReference Include="CommandLineParser">
<Version>2.8.0</Version>
</PackageReference>
<PackageReference Include="HtmlSanitizer">
<Version>5.0.372</Version>
</PackageReference>
<PackageReference Include="ILMerge" Condition=" '$(TargetFramework)' == 'net48'">
<Version>3.0.41</Version>
</PackageReference>
<PackageReference Include="Markdig">
<Version>0.22.0</Version>
</PackageReference>
<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

<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
</ItemGroup>
<Target Name="Publish net6" Condition=" '$(TargetFramework)' == 'net6.0' And '$([MSBuild]::IsOSPlatform(`Windows`))' == 'True' " AfterTargets="Build">
<CallTarget Targets="Publish" />
<Exec Command="if not exist $(SharedOutputPath) mkdir $(SharedOutputPath)"/>
<Copy SourceFiles="$(OutputPath)win10-x64\publish\Md2Html.exe" DestinationFolder="$(SharedOutputPath)" />
</Target>
<Target Name="AfterBuildOps" AfterTargets="Build" Condition=" '$(TargetFramework)' == 'net48' And '$([MSBuild]::IsOSPlatform(`Windows`))' == 'True'">
<Exec Command="if not exist $(SharedOutputPath) mkdir $(SharedOutputPath)"/>
<!-- the ILMergePath property points to the location of ILMerge.exe console application -->
<Exec Command="$(ILMergeConsolePath) $(OutputPath)Md2Html.exe ^
/allowDup ^
/lib:$(OutputPath) ^
/out:$(SharedOutputPath)Md2Html.exe ^
AngleSharp.Css.dll ^
AngleSharp.dll ^
HtmlSanitizer.dll ^
Markdig.dll ^
NDesk.Options.dll ^
CommandLine.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)"/>
</Target>
<Copy SourceFiles="$(OutputPath)Md2Html.exe" DestinationFolder="$(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.

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