-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancements for building licenses for applications (#22)
- Loading branch information
Showing
26 changed files
with
1,310 additions
and
395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,39 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.28307.421 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NugetUtility", "src\\NugetUtility.csproj", "{03100542-3DCF-4DFF-8357-9862CCB7EDC4}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{03100542-3DCF-4DFF-8357-9862CCB7EDC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{03100542-3DCF-4DFF-8357-9862CCB7EDC4}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{03100542-3DCF-4DFF-8357-9862CCB7EDC4}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{03100542-3DCF-4DFF-8357-9862CCB7EDC4}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {700E1E7A-220C-47D2-9D2B-EF080CD42ACA} | ||
EndGlobalSection | ||
EndGlobal | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30011.22 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NugetUtility", "src\NugetUtility.csproj", "{03100542-3DCF-4DFF-8357-9862CCB7EDC4}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NugetUtility.Tests", "tests\NugetUtility.Tests\NugetUtility.Tests.csproj", "{469490F0-DD86-4FAD-ADBD-D8D151F9EADA}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_SolutionItems", "_SolutionItems", "{5BF8EC73-735D-4349-97E6-CA1B8C4B758B}" | ||
ProjectSection(SolutionItems) = preProject | ||
.gitignore = .gitignore | ||
.travis.yml = .travis.yml | ||
LICENSE = LICENSE | ||
README.md = README.md | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{03100542-3DCF-4DFF-8357-9862CCB7EDC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{03100542-3DCF-4DFF-8357-9862CCB7EDC4}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{03100542-3DCF-4DFF-8357-9862CCB7EDC4}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{03100542-3DCF-4DFF-8357-9862CCB7EDC4}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{469490F0-DD86-4FAD-ADBD-D8D151F9EADA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{469490F0-DD86-4FAD-ADBD-D8D151F9EADA}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{469490F0-DD86-4FAD-ADBD-D8D151F9EADA}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{469490F0-DD86-4FAD-ADBD-D8D151F9EADA}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {700E1E7A-220C-47D2-9D2B-EF080CD42ACA} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace NugetUtility | ||
{ | ||
public class InvalidLicensesException : Exception | ||
{ | ||
public InvalidLicensesException(ValidationResult validationResult, ICollection<string> allowedLicenses) : base(GetMessage(validationResult, allowedLicenses)) | ||
{ | ||
} | ||
|
||
private static string GetMessage(ValidationResult validationResult, ICollection<string> allowedLicenses) | ||
{ | ||
allowedLicenses = allowedLicenses ?? Array.Empty<string>(); | ||
|
||
return $"Only the following packages are allowed: {string.Join(", ", allowedLicenses.ToArray())}{Environment.NewLine}" | ||
+ string.Join(Environment.NewLine, validationResult.InvalidPackages.Select(x => | ||
{ | ||
return $"Project ({x.Key}) Package({x.Value.Metadata.Id}-{x.Value.Metadata.Version}) LicenseUrl({x.Value.Metadata.LicenseUrl}) License Type ({x.Value.Metadata.License?.Text})"; | ||
})); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace NugetUtility | ||
{ | ||
public class LibraryNameAndVersionComparer : IEqualityComparer<LibraryInfo> | ||
{ | ||
public static LibraryNameAndVersionComparer Default = new LibraryNameAndVersionComparer(); | ||
|
||
public bool Equals([AllowNull] LibraryInfo x, [AllowNull] LibraryInfo y) | ||
{ | ||
return x?.PackageName == y?.PackageName | ||
&& x?.PackageVersion == y?.PackageVersion; | ||
} | ||
|
||
public int GetHashCode([DisallowNull] LibraryInfo obj) | ||
{ | ||
return obj.PackageName.GetHashCode() ^ obj.PackageVersion.GetHashCode(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace NugetUtility | ||
{ | ||
public class LicenseToUrlMappings : Dictionary<string, string> | ||
{ | ||
public LicenseToUrlMappings() { } | ||
|
||
public LicenseToUrlMappings(IDictionary<string, string> dictionary) : base(dictionary) | ||
{ | ||
} | ||
|
||
public static LicenseToUrlMappings Default { get; } = new LicenseToUrlMappings | ||
{ | ||
{ "http://www.apache.org/licenses/LICENSE-2.0.html", "Apache2.0" }, | ||
{ "http://www.apache.org/licenses/LICENSE-2.0", "Apache2.0" }, | ||
{ "http://aws.amazon.com/apache2.0/", "Apache2.0" }, | ||
{ "https://opensource.org/licenses/MS-PL", "MS-PL" } | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace NugetUtility | ||
{ | ||
public enum LogLevel | ||
{ | ||
None = 0, | ||
Verbose = 100, | ||
Information = 200, | ||
Warning = 300, | ||
Error = 400, | ||
Always = 500 | ||
} | ||
} |
Oops, something went wrong.