From 19bf3ffad93cbc4cc5e3f9fa87db3046246f9096 Mon Sep 17 00:00:00 2001 From: Simon Ensslen Date: Mon, 26 Feb 2024 17:27:00 +0100 Subject: [PATCH] don't pack netframework as tool, as this is not supported --- .github/workflows/action.yml | 48 +++++++++++++++++-- .../workflows/assets/App/projectsToCheck.json | 2 +- .github/workflows/release.yml | 20 ++++---- NuGetUtility.sln | 42 ++++++++++++++++ src/NuGetLicenseCore/NuGetLicenseCore.csproj | 40 ++++++++++++++++ src/NuGetLicenseCore/Program.cs | 18 +++++++ .../NuGetLicenseFramework.csproj | 36 ++++++++++++++ src/NuGetLicenseFramework/Program.cs | 18 +++++++ src/NuGetUtility/AppLifetime.cs | 2 +- src/NuGetUtility/NuGetUtility.csproj | 10 ++-- src/NuGetUtility/Program.cs | 7 --- 11 files changed, 213 insertions(+), 30 deletions(-) create mode 100644 src/NuGetLicenseCore/NuGetLicenseCore.csproj create mode 100644 src/NuGetLicenseCore/Program.cs create mode 100644 src/NuGetLicenseFramework/NuGetLicenseFramework.csproj create mode 100644 src/NuGetLicenseFramework/Program.cs diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 4ab07a9a..a39dea38 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -110,10 +110,10 @@ jobs: run: dotnet restore -p:TargetFramework=${{ matrix.targetFramework }} - name: build - run: dotnet publish ./src/NuGetUtility/NuGetUtility.csproj --configuration Release -o ./release -f ${{ matrix.targetFramework }} --no-restore + run: dotnet publish ./src/NuGetLicenseCore/NuGetLicenseCore.csproj --configuration Release -o ./release -f ${{ matrix.targetFramework }} --no-restore - name: check - run: dotnet ./release/NuGetUtility.dll -ji ./.github/workflows/assets/${{ matrix.project }}/projectsToCheck.json -t -a ./.github/workflows/assets/${{ matrix.project }}/allowedLicenses.json -o JsonPretty -override ./.github/workflows/assets/${{ matrix.project }}/overwritePackageInformation.json -ignore ./.github/workflows/assets/${{ matrix.project }}/ignorePackages.json -mapping ./.github/workflows/assets/${{ matrix.project }}/urlToLicenseMapping.json -d ./licenses/${{ matrix.project }}/${{ matrix.targetFramework }} + run: dotnet ./release/NuGetLicenseCore.dll -ji ./.github/workflows/assets/${{ matrix.project }}/projectsToCheck.json -t -a ./.github/workflows/assets/${{ matrix.project }}/allowedLicenses.json -o JsonPretty -override ./.github/workflows/assets/${{ matrix.project }}/overwritePackageInformation.json -ignore ./.github/workflows/assets/${{ matrix.project }}/ignorePackages.json -mapping ./.github/workflows/assets/${{ matrix.project }}/urlToLicenseMapping.json -d ./licenses/${{ matrix.project }}/${{ matrix.targetFramework }} - name: show downloaded licenses shell: pwsh @@ -124,6 +124,46 @@ jobs: Get-Content $file.FullName Write-Host ::endgroup:: } + check_licenses_framework: + runs-on: windows-latest + strategy: + matrix: + project: [App, Tests] + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: nuget/setup-nuget@v2 + - run: nuget restore NuGetUtility.sln + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v2 + + - name: fully qualify artifacts path + id: release_path + shell: pwsh + run: | + $path = [System.IO.Path]::GetFullPath("./release"); + echo "publish to path: $path" + echo "path={$path}" >> $GITHUB_OUTPUT + + - name: build + run: msbuild ./src/NuGetLicenseFramework/NuGetLicenseFramework.csproj /t:Publish /p:configuration=Release /p:PublishDir=${{ steps.release_path.path }}/net472 + + - name: check + run: ./release/NuGetLicenseFramework.exe -ji ./.github/workflows/assets/${{ matrix.project }}/projectsToCheck.json -t -a ./.github/workflows/assets/${{ matrix.project }}/allowedLicenses.json -o JsonPretty -override ./.github/workflows/assets/${{ matrix.project }}/overwritePackageInformation.json -ignore ./.github/workflows/assets/${{ matrix.project }}/ignorePackages.json -mapping ./.github/workflows/assets/${{ matrix.project }}/urlToLicenseMapping.json -d ./licenses/${{ matrix.project }} + + - name: show downloaded licenses + shell: pwsh + run: | + foreach($file in Get-ChildItem -Path ./licenses/${{ matrix.project }}) + { + Write-Host ::group::$file + Get-Content $file.FullName + Write-Host ::endgroup:: + } check_version_command: runs-on: ubuntu-latest @@ -162,12 +202,12 @@ jobs: version_format: "${major}.${minor}.${patch}-test${increment}" - name: build - run: dotnet publish ./src/NuGetUtility/NuGetUtility.csproj --configuration Release -o ./release -f ${{ matrix.targetFramework }} --no-restore -p:Version=${{ steps.version.outputs.version }} + run: dotnet publish ./src/NuGetLicenseCore/NuGetLicenseCore.csproj --configuration Release -o ./release -f ${{ matrix.targetFramework }} --no-restore -p:Version=${{ steps.version.outputs.version }} - name: check app version shell: pwsh run: | - $cmdOutput = dotnet ./release/NuGetUtility.dll --version | Out-String + $cmdOutput = dotnet ./release/NuGetLicenseCore.dll --version | Out-String if(!($cmdOutput.Trim() -like '${{ steps.version.outputs.version }}')) { Write-Host Versions do not match: read $cmdOutput, expected ${{ steps.version.outputs.version }} exit 1; diff --git a/.github/workflows/assets/App/projectsToCheck.json b/.github/workflows/assets/App/projectsToCheck.json index dea169f2..91bcdb8e 100644 --- a/.github/workflows/assets/App/projectsToCheck.json +++ b/.github/workflows/assets/App/projectsToCheck.json @@ -1 +1 @@ -["./src/NuGetUtility/NuGetUtility.csproj"] +["./src/NuGetLicenseCore/NuGetLicenseCore.csproj","./src/NuGetLicenseFramework/NuGetLicenseFramework.csproj"] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 79502da5..27061cea 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,21 +48,21 @@ jobs: id: artifacts_path shell: pwsh run: | - New-Item -ItemType "directory" -Path "./artifacts" - $path = Resolve-Path ./artifacts - echo "::set-output name=path::$path" + $path = [System.IO.Path]::GetFullPath("./artifacts"); + echo "publish to path: $path" + echo "path={$path}" >> $GITHUB_OUTPUT - name: Publish the application binaries (.net6) - run: msbuild ./src/NuGetUtility/NuGetUtility.csproj /t:Publish /p:configuration=Release /p:OutDir=${{ steps.artifacts_path.path}}/net6 /p:TargetFramework=net6.0 /p:Version=${{ steps.version.outputs.full_without_prefix }} + run: dotnet publish ./src/NuGetLicenseCore/NuGetLicenseCore.csproj -c Release --no-restore -o ${{ steps.artifacts_path.path }}/net6 -f net6.0 -p:Version=${{ steps.version.outputs.full_without_prefix }} - name: Publish the application binaries (.net7) - run: msbuild ./src/NuGetUtility/NuGetUtility.csproj /t:Publish /p:configuration=Release /p:OutDir=${{ steps.artifacts_path.path}}/net7 /p:TargetFramework=net7.0 /p:Version=${{ steps.version.outputs.full_without_prefix }} + run: dotnet publish ./src/NuGetLicenseCore/NuGetLicenseCore.csproj -c Release --no-restore -o ${{ steps.artifacts_path.path }}/net7 -f net7.0 -p:Version=${{ steps.version.outputs.full_without_prefix }} - name: Publish the application binaries (.net8) - run: msbuild ./src/NuGetUtility/NuGetUtility.csproj /t:Publish /p:configuration=Release /p:OutDir=${{ steps.artifacts_path.path}}/net8 /p:TargetFramework=net8.0 /p:Version=${{ steps.version.outputs.full_without_prefix }} + run: dotnet publish ./src/NuGetLicenseCore/NuGetLicenseCore.csproj -c Release --no-restore -o ${{ steps.artifacts_path.path }}/net8 -f net8.0 -p:Version=${{ steps.version.outputs.full_without_prefix }} - name: Publish the application binaries (.net472) - run: msbuild ./src/NuGetUtility/NuGetUtility.csproj /t:Publish /p:configuration=Release /p:OutDir=${{ steps.artifacts_path.path}}/net472 /p:TargetFramework=net472 /p:Version=${{ steps.version.outputs.full_without_prefix }} + run: msbuild ./src/NuGetLicenseFramework/NuGetLicenseFramework.csproj /t:Publish /p:configuration=Release /p:PublishDir=${{ steps.artifacts_path.path }}/net472 /p:Version=${{ steps.version.outputs.full_without_prefix }} - name: Create nuget package - run: msbuild ./src/NuGetUtility/NuGetUtility.csproj /t:Pack /p:configuration=Release /p:OutDir=${{ steps.artifacts_path.path}} /p:Version=${{ steps.version.outputs.full_without_prefix }} - + run: dotnet pack ./src/NuGetLicenseCore/NuGetLicenseCore.csproj -c Release --no-build -o ${{ steps.artifacts_path.path }} -p:Version=${{ steps.version.outputs.full_without_prefix }} + - name: Zip artifacts uses: thedoctor0/zip-release@0.7.6 with: @@ -81,4 +81,4 @@ jobs: - name: publish nuget package to nuget.org id: publish_nuget - run: dotnet nuget push ${{ steps.artifacts_path.path}}/*.nupkg -s 'https://api.nuget.org/v3/index.json' -k ${{secrets.NUGET_KEY}} --skip-duplicate + run: dotnet nuget push ${{ steps.artifacts_path.path }}/*.nupkg -s 'https://api.nuget.org/v3/index.json' -k ${{ secrets.NUGET_KEY }} --skip-duplicate diff --git a/NuGetUtility.sln b/NuGetUtility.sln index 074624cb..910955a0 100644 --- a/NuGetUtility.sln +++ b/NuGetUtility.sln @@ -31,6 +31,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleCppProject", "tests\targets\SimpleCppProject\SimpleCppProject.vcxproj", "{380FBD90-2CF0-4F83-A58E-EB98CE2EAE15}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetLicenseCore", "src\NuGetLicenseCore\NuGetLicenseCore.csproj", "{FBA6622A-C9E3-4250-AB79-35F02CAD2419}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetLicenseFramework", "src\NuGetLicenseFramework\NuGetLicenseFramework.csproj", "{DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -184,6 +188,42 @@ Global {380FBD90-2CF0-4F83-A58E-EB98CE2EAE15}.TestWindows|x64.Build.0 = Debug|x64 {380FBD90-2CF0-4F83-A58E-EB98CE2EAE15}.TestWindows|x86.ActiveCfg = Debug|Win32 {380FBD90-2CF0-4F83-A58E-EB98CE2EAE15}.TestWindows|x86.Build.0 = Debug|Win32 + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.Debug|x64.ActiveCfg = Debug|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.Debug|x64.Build.0 = Debug|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.Debug|x86.ActiveCfg = Debug|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.Debug|x86.Build.0 = Debug|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.Release|Any CPU.Build.0 = Release|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.Release|x64.ActiveCfg = Release|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.Release|x64.Build.0 = Release|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.Release|x86.ActiveCfg = Release|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.Release|x86.Build.0 = Release|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.TestWindows|Any CPU.ActiveCfg = Debug|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.TestWindows|Any CPU.Build.0 = Debug|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.TestWindows|x64.ActiveCfg = Debug|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.TestWindows|x64.Build.0 = Debug|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.TestWindows|x86.ActiveCfg = Debug|Any CPU + {FBA6622A-C9E3-4250-AB79-35F02CAD2419}.TestWindows|x86.Build.0 = Debug|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.Debug|x64.ActiveCfg = Debug|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.Debug|x64.Build.0 = Debug|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.Debug|x86.ActiveCfg = Debug|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.Debug|x86.Build.0 = Debug|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.Release|Any CPU.Build.0 = Release|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.Release|x64.ActiveCfg = Release|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.Release|x64.Build.0 = Release|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.Release|x86.ActiveCfg = Release|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.Release|x86.Build.0 = Release|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.TestWindows|Any CPU.ActiveCfg = Debug|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.TestWindows|Any CPU.Build.0 = Debug|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.TestWindows|x64.ActiveCfg = Debug|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.TestWindows|x64.Build.0 = Debug|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.TestWindows|x86.ActiveCfg = Debug|Any CPU + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F}.TestWindows|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -198,6 +238,8 @@ Global {3DDEC6CB-4FDA-49D1-A358-06BE9200C174} = {FA92392F-D895-4D1E-A5ED-E6DC3C08223E} {3150479E-4370-408D-8A93-7C0CDC281CC3} = {FA92392F-D895-4D1E-A5ED-E6DC3C08223E} {380FBD90-2CF0-4F83-A58E-EB98CE2EAE15} = {FA92392F-D895-4D1E-A5ED-E6DC3C08223E} + {FBA6622A-C9E3-4250-AB79-35F02CAD2419} = {D2AB2D00-1F48-487D-BFE0-99FDB4E071CC} + {DE079B9C-B6BA-4D53-8B83-03D3CBD4027F} = {D2AB2D00-1F48-487D-BFE0-99FDB4E071CC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {70887D40-0182-4C32-BFA1-B5A02E405F11} diff --git a/src/NuGetLicenseCore/NuGetLicenseCore.csproj b/src/NuGetLicenseCore/NuGetLicenseCore.csproj new file mode 100644 index 00000000..fcacf09c --- /dev/null +++ b/src/NuGetLicenseCore/NuGetLicenseCore.csproj @@ -0,0 +1,40 @@ + + + + Exe + net6.0;net7.0;net8.0 + true + true + DotnetTool + git + 100.100.100 + false + nuget-license + nuget-license + Tom Chavakis,Simon Ensslen + - + .NET Tool to print and validate the licenses of dotnet project(s) + https://github.com/sensslen/nuget-license + Apache-2.0 + false + false + enable + enable + Debug;Release;TestWindows + AnyCPU + README.md + A .net tool to print and validate the licenses of .net code. This tool supports .NET (Core), .NET Standard and .NET Framework projects. + + + + + true + README.md + + + + + + + + diff --git a/src/NuGetLicenseCore/Program.cs b/src/NuGetLicenseCore/Program.cs new file mode 100644 index 00000000..853588ff --- /dev/null +++ b/src/NuGetLicenseCore/Program.cs @@ -0,0 +1,18 @@ +// Licensed to the projects contributors. +// The license conditions are provided in the LICENSE file located in the project root + +using McMaster.Extensions.CommandLineUtils; +using NuGetUtility; + +namespace NuGetLicenseCore +{ + public static class Program + { + public static async Task Main(string[] args) + { + var lifetime = new AppLifetime(); + int returnCode = await CommandLineApplication.ExecuteAsync(args, lifetime.Token); + lifetime.Done(returnCode); + } + } +} diff --git a/src/NuGetLicenseFramework/NuGetLicenseFramework.csproj b/src/NuGetLicenseFramework/NuGetLicenseFramework.csproj new file mode 100644 index 00000000..b43b6c58 --- /dev/null +++ b/src/NuGetLicenseFramework/NuGetLicenseFramework.csproj @@ -0,0 +1,36 @@ + + + + Exe + net472 + git + 100.100.100 + false + nuget-license + nuget-license + Tom Chavakis,Simon Ensslen + - + .NET Tool to print and validate the licenses of dotnet project(s) + https://github.com/sensslen/nuget-license + Apache-2.0 + false + enable + enable + Debug;Release;TestWindows + AnyCPU + A .net tool to print and validate the licenses of .net code. This tool supports .NET (Core), .NET Standard and .NET Framework projects. + 10.0 + + + + + true + README.md + + + + + + + + diff --git a/src/NuGetLicenseFramework/Program.cs b/src/NuGetLicenseFramework/Program.cs new file mode 100644 index 00000000..e03eb2f7 --- /dev/null +++ b/src/NuGetLicenseFramework/Program.cs @@ -0,0 +1,18 @@ +// Licensed to the projects contributors. +// The license conditions are provided in the LICENSE file located in the project root + +using McMaster.Extensions.CommandLineUtils; +using NuGetUtility; + +namespace NuGetLicenseFramework +{ + public static class Program + { + public static async Task Main(string[] args) + { + var lifetime = new AppLifetime(); + int returnCode = await CommandLineApplication.ExecuteAsync(args, lifetime.Token); + lifetime.Done(returnCode); + } + } +} diff --git a/src/NuGetUtility/AppLifetime.cs b/src/NuGetUtility/AppLifetime.cs index b1cd8e32..72d02d55 100644 --- a/src/NuGetUtility/AppLifetime.cs +++ b/src/NuGetUtility/AppLifetime.cs @@ -6,7 +6,7 @@ namespace NuGetUtility /// /// Inspired by: https://github.com/dotnet/aspnetcore/search?q=WebHostLifetime /// - internal class AppLifetime + public class AppLifetime { private readonly CancellationTokenSource _cts = new CancellationTokenSource(); private readonly ManualResetEventSlim _doneEvent = new ManualResetEventSlim(); diff --git a/src/NuGetUtility/NuGetUtility.csproj b/src/NuGetUtility/NuGetUtility.csproj index a7666c1e..d99a19c4 100644 --- a/src/NuGetUtility/NuGetUtility.csproj +++ b/src/NuGetUtility/NuGetUtility.csproj @@ -1,19 +1,15 @@ - Exe net472;net6.0;net7.0;net8.0 true - true - DotnetTool git 100.100.100 false - nuget-license - nuget-license + nuget-license-core Tom Chavakis,Simon Ensslen - - .NET Core Tool to print and validate the licenses of dotnet project(s) + .NET Tool to print and validate the licenses of dotnet project(s) https://github.com/sensslen/nuget-license Apache-2.0 false @@ -23,7 +19,7 @@ Debug;Release;TestWindows AnyCPU README.md - A .net core tool to print and validate the licenses of .net code. This tool supports .NET (Core), .NET Standard and .NET Framework projects. + A .net tool to print and validate the licenses of .net code. This tool supports .NET (Core), .NET Standard and .NET Framework projects. diff --git a/src/NuGetUtility/Program.cs b/src/NuGetUtility/Program.cs index 22a2b247..9da89604 100644 --- a/src/NuGetUtility/Program.cs +++ b/src/NuGetUtility/Program.cs @@ -90,13 +90,6 @@ public class Program private static string GetVersion() => typeof(Program).Assembly.GetCustomAttribute()?.InformationalVersion ?? string.Empty; - public static async Task Main(string[] args) - { - var lifetime = new AppLifetime(); - int returnCode = await CommandLineApplication.ExecuteAsync(args, lifetime.Token); - lifetime.Done(returnCode); - } - private async Task OnExecuteAsync(CancellationToken cancellationToken) { using var httpClient = new HttpClient();