添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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

My Build Pipe line fails on the nuget restore task in Azure Devops. I set my build agent to: windows-latest

The logging of my build pipe line is as follows:

Detected NuGet version 6.4.0.123 / 6.4.0+da5b9fa1595e212914854a9ff4a18a6759ed4729.da5b9fa1595e212914854a9ff4a18a6759ed4729
C:\hostedtoolcache\windows\NuGet\6.4.0\x64\nuget.exe sources Add -NonInteractive -Name 7cc32ed4-d773-4d44-8aaf-5d1f764362a4 -Source https://marcelbeeker.pkgs.visualstudio.com/613d6b9d-285e-48ec-a9ce-004b0a3321ff/_packaging/7cc32ed4-d773-4d44-8aaf-5d1f764362a4/nuget/v3/index.json -ConfigFile D:\a\1\Nuget\tempNuGet_1800.config
Package source with Name: 7cc32ed4-d773-4d44-8aaf-5d1f764362a4 added successfully.
C:\hostedtoolcache\windows\NuGet\6.4.0\x64\nuget.exe sources Add -NonInteractive -Name NuGetOrg -Source https://api.nuget.org/v3/index.json -ConfigFile D:\a\1\Nuget\tempNuGet_1800.config
Package source with Name: NuGetOrg added successfully.
C:\hostedtoolcache\windows\NuGet\6.4.0\x64\nuget.exe restore D:\a\1\s\SecondMobileApp\SecondMobileApp.sln -Verbosity Detailed -NonInteractive -ConfigFile D:\a\1\Nuget\tempNuGet_1800.config
C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [D:\a\1\s\SecondMobileApp\SecondMobileApp.Exceptions\SecondMobileApp.Exceptions.csproj]
NuGet Version: 6.4.0.123
C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [D:\a\1\s\SecondMobileApp\SecondMobileApp.Standard.Data\SecondMobileApp.Standard.Data.csproj]
MSBuild auto-detection: using msbuild version '17.3.1.41501' from 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [D:\a\1\s\SecondMobileApp\SecondMobileApp.Standard.Data.Tests\SecondMobileApp.Standard.Data.Tests.csproj]
MSBuild P2P timeout [ms]: 120000
C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [D:\a\1\s\SecondMobileApp\SecondMobileApp.Service\SecondMobileApp.Service.csproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin\msbuild.exe "C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\s0oibtaf.fl5.nugetinputs.targets" /t:GenerateRestoreGraphFile /nologo /nr:false /v:q /p:NuGetRestoreTargets="C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\ic1gf4g1.z04.nugetrestore.targets" /p:RestoreUseCustomAfterTargets="True" /p:DisableCheckingDuplicateNuGetItems="True" /p:RestoreTaskAssemblyFile="C:\hostedtoolcache\windows\NuGet\6.4.0\x64\nuget.exe" /p:RestoreSolutionDirectory="D:\a\1\s\SecondMobileApp\" /p:RestoreConfigFile="D:\a\1\Nuget\tempNuGet_1800.config" /p:SolutionDir="D:\a\1\s\SecondMobileApp\" /p:SolutionName="SecondMobileApp"
C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [D:\a\1\s\SecondMobileApp\SecondMobileApp.Service.Tests\SecondMobileApp.Service.Tests.csproj]
NuGet.CommandLine.ExitCodeException: Exception of type 'NuGet.CommandLine.ExitCodeException' was thrown.
C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [D:\a\1\s\SecondMobileApp\SecondMobileApp.MAUI\SecondMobileApp.MAUI.csproj]
at NuGet.CommandLine.MsBuildUtility.d__6.MoveNext()

--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.CommandLine.RestoreCommand.d__68.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.CommandLine.RestoreCommand.d__63.MoveNext()
##[error]The nuget command failed with exit code(1) and error(C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [D:\a\1\s\SecondMobileApp\SecondMobileApp.Exceptions\SecondMobileApp.Exceptions.csproj]
C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [D:\a\1\s\SecondMobileApp\SecondMobileApp.Standard.Data\SecondMobileApp.Standard.Data.csproj]
C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [D:\a\1\s\SecondMobileApp\SecondMobileApp.Standard.Data.Tests\SecondMobileApp.Standard.Data.Tests.csproj]
C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [D:\a\1\s\SecondMobileApp\SecondMobileApp.Service\SecondMobileApp.Service.csproj]
C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [D:\a\1\s\SecondMobileApp\SecondMobileApp.Service.Tests\SecondMobileApp.Service.Tests.csproj]
C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [D:\a\1\s\SecondMobileApp\SecondMobileApp.MAUI\SecondMobileApp.MAUI.csproj])
##[error]Packages failed to restore
Finishing: NuGet restore

Not sure if below helps however the agents dont appear to have been updated to include dotnet core 7. This usually takes some time after releases. The following YAML should work to install the SDK.

pool:
  vmImage: ubuntu-latest
steps:
- task: UseDotNet@2
  displayName: 'Use .NET Core sdk'
  inputs:
    packageType: sdk
    version: 7.x
    installationPath: $(Agent.ToolsDirectory)/dotnet

This will then output as

Starting: Use .NET Core sdk
==============================================================================
Task         : Use .NET Core
Description  : Acquires a specific version of the .NET Core SDK from the internet or the local cache and adds it to the PATH. Use this task to change the version of .NET Core used in subsequent tasks. Additionally provides proxy support.
Version      : 2.207.2
Author       : Microsoft Corporation
Help         : https://aka.ms/AA4xgy0
==============================================================================
Tool to install: .NET Core sdk version 7.x.
Found version 7.0.100 in channel 7.0 for user specified version spec: 7.x
get-os-distro: Error: Distribution specific OS name and version could not be detected: UName = Linux
Version 7.0.100 was not found in cache.
Getting URL to download .NET Core sdk version: 7.0.100.
Detecting OS platform to find correct download package for the OS.
/home/vsts/work/_tasks/UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6/2.207.2/externals/get-os-distro.sh
Primary:linux-x64
Legacy:-x64
Detected platform (Primary): linux-x64
Detected platform (Legacy): -x64
Downloading: https://download.visualstudio.microsoft.com/download/pr/253e5af8-41aa-48c6-86f1-39a51b44afdc/5bb2cb9380c5b1a7f0153e0a2775727b/dotnet-sdk-7.0.100-linux-x64.tar.gz
Extracting downloaded package /home/vsts/work/_temp/ab99ef9b-f3e3-4703-82b1-aac5b5263908.
Extracting archive
/usr/bin/tar xC /home/vsts/work/_temp/cc557f91-2966-49ce-ae41-8ab8379b6d19 -f /home/vsts/work/_temp/ab99ef9b-f3e3-4703-82b1-aac5b5263908
Successfully installed .NET Core sdk version 7.0.100.
Creating global tool path and pre-pending to PATH.
Finishing: Use .NET Core sdk

Here is the full pipelines (as a test)

pool: vmImage: ubuntu-latest steps: - checkout: none - task: UseDotNet@2 displayName: 'Use .NET Core sdk' inputs: packageType: sdk version: 7.x installationPath: $(Agent.ToolsDirectory)/dotnet - pwsh: | dotnet new console -f net7.0 -o ./MyTestConsole cd ./MyTestConsole dotnet build -c Release

In last year's similar discussion I mentioned that it'd be nice for the pipeline to look at the version within the project instead of having to define it twice (see here: #6907 (comment)). Has any progress been made on that? It seems like it'd stop this from being a yearly issue every November when a new version is released.

As a workaround I have been using the UseDotNet@2 task, but it seems to fail more times than it works. I am curious why this wouldn't work 100% of the time.

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 7.x'
  inputs:
    version: 7.x
2022-11-17T17:08:07.9357944Z ##[section]Starting: Use .NET Core sdk 
2022-11-17T17:08:07.9679191Z ==============================================================================
2022-11-17T17:08:07.9679549Z Task         : Use .NET Core
2022-11-17T17:08:07.9680108Z Description  : Acquires a specific version of the .NET Core SDK from the internet or the local cache and adds it to the PATH. Use this task to change the version of .NET Core used in subsequent tasks. Additionally provides proxy support.
2022-11-17T17:08:07.9680670Z Version      : 2.207.2
2022-11-17T17:08:07.9680874Z Author       : Microsoft Corporation
2022-11-17T17:08:07.9681094Z Help         : https://aka.ms/AA4xgy0
2022-11-17T17:08:07.9681462Z ==============================================================================
2022-11-17T17:08:12.4846365Z No matching sdk version could be found for specified version: 7.0.0 Kindly note the preview versions are only considered in latest version searches if Include Preview Versions checkbox is checked.
2022-11-17T17:08:12.4847624Z Version 7.0.0 could not be found in its channel, will now search in adjacent channels.
2022-11-17T17:08:12.4850663Z Searching for version in channel 7.0
2022-11-17T17:08:12.8140186Z ##[error]sdk version matching: 7.0.0 could not be found
2022-11-17T17:08:12.8277722Z ##[section]Finishing: Use .NET Core sdk
          

@paulczy probably a new issue is better but I think https://github.com/microsoft/azure-pipelines-tasks/ is the best place for this.

We've been using the same task for our pipeline without issues.

Azure DevOps Pipeline doesn't support .NET 7 & macos-latest for building .Net Maui iOS apps #7995

While this does provide a workaround in the interim, it adds a good 1.5mins to all our build pipelines which has a meaningful
impact on dev process.

Any ETA on when the .NET 7 SDK will be included in Pipelines out-of-the-box?

Tracking the Azure DevOps release notes (or the Pipelines release notes specifically) there doesn't seem to have been a release since Nov 2, 2022 – before .NET 7 was officially released.

@superjulius Fantastic, looks like it's indeed now working! 🎉

Seems like the UseDotNet@2 task is not smart enough to know to use the system version if it's already installed, so the following Pipelines task:

steps:
  # .NET
  # include the .NET SDK explicitly (NOTE: needed around version updates) 
  - task: UseDotNet@2
    inputs:
      packageType: 'sdk'
      useGlobalJson: true
    displayName: 'Use .NET SDK'

still ends up downloading a fresh version of the SDK ("Version 7.0.100 was not found in cache") even though it's a perfect match, thus we never detected the actual VM inclusion despite being on the lookout for it in our builds.

Found version 7.0.100 in channel 7.0 for user specified version spec: 7.0.100
Getting URL to download .NET Core sdk version: 7.0.100.
Detecting OS platform to find correct download package for the OS.
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "& 'D:\a\_tasks\UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6\2.207.2\externals\get-os-platform.ps1'"
Primary:win-x64
Detected platform (Primary): win-x64
Version 7.0.100 was not found in cache.
Downloading: https://download.visualstudio.microsoft.com/download/pr/1fb808dc-d017-4460-94f8-bf1ac83e6cd8/756b301e714755e411b84684b885a516/dotnet-sdk-7.0.100-win-x64.zip
Extracting downloaded package D:\a\_temp\a24f2c52-8dad-4143-b1b0-13d532a97afa.
Extracting archive

Anyways glad we're past it!

Looks like it has gone in the VM on Nov 24 (commit).