Inedo / pgscan

Dependency scanner for ProGet.
MIT License
11 stars 5 forks source link

pgscan fails because it uses .Net 7 #44

Closed HeSitates closed 5 months ago

HeSitates commented 5 months ago

We have removed some old stuff on our build server and now one build fails, all other builds build without a problem.

The app itself is build (still .Net 6), but pgscan uses .Net 7 (no SDK installed) and then fails.

variables:
- name: MajorVersion
  value: 24
- name: MinorVersion
  value: 2
- name: BuildConfiguration
  value: 'release'
- name: BuildPlatform
  value: 'any cpu'

steps:
- checkout: self
  clean: true

- task: NuGetToolInstaller@0
  displayName: Use NuGet 6.x
  inputs:
    versionSpec: 6.x

- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '8.x'

- task: NodeTool@0
  displayName: Use Node 20.x
  inputs:
    versionSpec: 20.x

- task: CmdLine@2
  displayName: 'Install pgscan'
  condition: succeeded()
  inputs:
    script: 'dotnet tool install pgscan'

- task: CmdLine@2
  displayName: 'Run pgscan <PRODUCTNAME>'
  condition: succeeded()
  inputs:
    script: dotnet tool run pgscan identify --type=nuget --input="$(Build.SourcesDirectory)\<PRODUCTNAME>\<PRODUCTNAME>.sln" --project-name="$(SonarQubeName) <PRODUCTNAME>" --version=$(MajorVersion).$(MinorVersion) --project-type=application --proget-url=https://packages.nl/ --api-key=$(PROGETAPIKEY)

I've tried the build with .Net SDK 6 and 8, but it makes no difference. The log of the failing build step:

2024-01-15T13:09:52.0936973Z ##[section]Starting: Run pgscan <PRODUCTNAME>
2024-01-15T13:09:52.1077188Z ==============================================================================
2024-01-15T13:09:52.1077492Z Task         : Command line
2024-01-15T13:09:52.1077604Z Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
2024-01-15T13:09:52.1077801Z Version      : 2.201.1
2024-01-15T13:09:52.1077898Z Author       : Microsoft Corporation
2024-01-15T13:09:52.1078084Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
2024-01-15T13:09:52.1078245Z ==============================================================================
2024-01-15T13:09:53.0080884Z Generating script.
2024-01-15T13:09:53.0222702Z Script contents: shell
2024-01-15T13:09:53.0233544Z dotnet tool run pgscan identify --type=nuget --input="D:\Agents\Agent.Morpheus\_work\10\s\<PRODUCTNAME>\<PRODUCTNAME>.sln" --project-name="<PRODUCTNAME>" --version=24.2 --project-type=application --proget-url=https://packages.nl/ --api-key=***
2024-01-15T13:09:53.0613280Z ========================== Starting Command Output ===========================
2024-01-15T13:09:53.0866700Z ##[command]"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\Agents\Agent.Morpheus\_work\_temp\56048124-0d17-4886-9a91-c3aa98842501.cmd""
2024-01-15T13:09:53.3486533Z You must install or update .NET to run this application.
2024-01-15T13:09:53.3486769Z 
2024-01-15T13:09:53.3487435Z App: D:\NuGetCache\pgscan\1.5.8\tools\net7.0\any\pgscan.dll
2024-01-15T13:09:53.3487688Z Architecture: x64
2024-01-15T13:09:53.4029982Z Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)
2024-01-15T13:09:53.4031161Z .NET location: D:\Agents\Agent.Morpheus\_work\_tool\dotnet\
2024-01-15T13:09:53.4031485Z 
2024-01-15T13:09:53.4032168Z The following frameworks were found:
2024-01-15T13:09:53.4035125Z   6.0.19 at [D:\Agents\Agent.Morpheus\_work\_tool\dotnet\shared\Microsoft.NETCore.App]
2024-01-15T13:09:53.4037306Z   6.0.20 at [D:\Agents\Agent.Morpheus\_work\_tool\dotnet\shared\Microsoft.NETCore.App]
2024-01-15T13:09:53.4039285Z   6.0.21 at [D:\Agents\Agent.Morpheus\_work\_tool\dotnet\shared\Microsoft.NETCore.App]
2024-01-15T13:09:53.4049447Z   6.0.22 at [D:\Agents\Agent.Morpheus\_work\_tool\dotnet\shared\Microsoft.NETCore.App]
2024-01-15T13:09:53.4053962Z   6.0.23 at [D:\Agents\Agent.Morpheus\_work\_tool\dotnet\shared\Microsoft.NETCore.App]
2024-01-15T13:09:53.4054395Z   6.0.24 at [D:\Agents\Agent.Morpheus\_work\_tool\dotnet\shared\Microsoft.NETCore.App]
2024-01-15T13:09:53.4054806Z   6.0.25 at [D:\Agents\Agent.Morpheus\_work\_tool\dotnet\shared\Microsoft.NETCore.App]
2024-01-15T13:09:53.4055108Z   6.0.26 at [D:\Agents\Agent.Morpheus\_work\_tool\dotnet\shared\Microsoft.NETCore.App]
2024-01-15T13:09:53.4055356Z   8.0.1 at [D:\Agents\Agent.Morpheus\_work\_tool\dotnet\shared\Microsoft.NETCore.App]
2024-01-15T13:09:53.4055491Z 
2024-01-15T13:09:53.4055615Z Learn more:
2024-01-15T13:09:53.4055785Z https://aka.ms/dotnet/app-launch-failed
2024-01-15T13:09:53.4055896Z 
2024-01-15T13:09:53.4056050Z To install missing framework, download:
2024-01-15T13:09:53.4058395Z https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=7.0.0&arch=x64&rid=win-x64&os=win10
2024-01-15T13:09:53.5329894Z ##[error]Cmd.exe exited with code '-2147450730'.
2024-01-15T13:09:53.5794885Z ##[section]Finishing: Run pgscan <PRODUCTNAME>

What am I doing wrong?

whatatripp commented 5 months ago

Hmm, I'm not totally sure to be honest; when I look at pgscanTool.csproj, I see <TargetFrameworks>net6.0;net7.0</TargetFrameworks>.

So it should work if you have NET6 or NET7 installed?

gdivis commented 5 months ago

dotnet tools are a little funny - i think the package has to target the exact verison used to run the build, which in this case is net8.0. We'll add that as a target to pgscanTool, which should fix this.

HeSitates commented 5 months ago

So it should work if you have NET6 or NET7 installed? I can confirm that it does not do that. šŸ˜¢

dotnet tools are a little funny šŸ˜Š

i think the package has to target the exact verison used to run the build, which in this case is net8.0. We'll add that as a target to pgscanTool, which should fix this. That would be great! Thnxs!

gdivis commented 5 months ago

We've just published v1.5.11, which also targets net8.0 for the dotnet tool.