Forum Discussion

orush135's avatar
orush135
Copper Contributor
Jan 25, 2023

Issues Running the Local Agent

Hi all,

 

I have installed the local agent on a 2019 Windows Server to experiment with Azure Devops. Besides that I have installed the following components on the machine:

 

Git

dotnet-sdk-6.0.405-win-x64

 

I have used the Visual Studio 2022 latest version and the Asp .net Core Web App and published the project to an Azure Repo. The agent is online and I wasnt able to find anything in the Event Log on the Server. However, when I try to run the pipeline which runs based on the following yaml file:

 

# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:

trigger:
- main

pool:
name: Default

variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'

steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '6.x'
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'

- task: DotNetCoreCLI@2
displayName: Build
inputs:
command: build
projects: '**/*.csproj'
arguments: '--configuration $(buildConfiguration)'

- task: DotNetCoreCLI@2
inputs:
command: publish
publishWebProjects: True
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
 
 
I am experiencing the following in the NuGetCommand section of the job:
 
  1. C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\NuGetScratch\4gjz22ki.hk3.nugetrestore.targets(199,25): error MSB4066: The attribute "Version" in element <PackageReference> is unrecognized. [C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\NuGetScratch\hy554qkz.lbg.nugetinputs.targets]
    NuGet Version: 6.4.0.123
     
    MSBuild auto-detection: using msbuild version '4.0' from 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
    MSBuild P2P timeout [ms]: 120000
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe "C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\NuGetScratch\hy554qkz.lbg.nugetinputs.targets" /t:GenerateRestoreGraphFile /nologo /nr:false /v:q /p:NuGetRestoreTargets="C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\NuGetScratch\4gjz22ki.hk3.nugetrestore.targets" /p:RestoreUseCustomAfterTargets="True" /p:DisableCheckingDuplicateNuGetItems="True" /p:RestoreTaskAssemblyFile="C:\Agent\_work\_tool\NuGet\6.4.0\x64\nuget.exe" /p:RestoreSolutionDirectory="C:\Agent\_work\1\s\\" /p:RestoreConfigFile="C:\Agent\_work\1\Nuget\tempNuGet_21.config" /p:SolutionDir="C:\Agent\_work\1\s\\" /p:SolutionName="newelements" /p:RestoreBuildInParallel="False" /p:RestoreUseSkipNonexistentTargets="False"
    NuGet.CommandLine.ExitCodeException: Exception of type 'NuGet.CommandLine.ExitCodeException' was thrown.
    at NuGet.CommandLine.MsBuildUtility.<GetProjectReferencesAsync>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.<GetDependencyGraphSpecAsync>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.<DetermineInputsFromMSBuildAsync>d__63.MoveNext()
    ##[error]The nuget command failed with exit code(1) and error(C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\NuGetScratch\4gjz22ki.hk3.nugetrestore.targets(199,25): error MSB4066: The attribute "Version" in element <PackageReference> is unrecognized. [C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\NuGetScratch\hy554qkz.lbg.nugetinputs.targets])
    ##[error]Packages failed to restore
    Finishing: NuGetCommand
     
    Really need help here. I have tried different .net versions but that did not went anywhere. So thanks for help
 
 
 
 
 

 

  • varunmittal's avatar
    varunmittal
    Copper Contributor
    This error message suggests that there is an issue with the version of NuGet being used. The error message states "The attribute "Version" in element <PackageReference> is unrecognized" which suggests that the version of NuGet being used does not support the version attribute.

    You can try updating the NuGet version to the latest version. You can also try running the pipeline with a specific version of MSBuild by using the option -MSBuildVersion to force NuGet to use that version.

    Additionally, make sure that the version of dotnet-sdk that you have installed on your local agent matches the version specified in the pipeline. If the version of the SDK is not compatible with the version of NuGet, it can cause issues like this.

    Lastly, it is always good practice to clear the caches and temp folders in the local agent machine. Sometimes, the pipeline may be using an old version of the package, which can cause issues.
    • orush135's avatar
      orush135
      Copper Contributor

      varunmittal 

       

      Hi there,

       

      thank you for the answer. It is now the exact same version of .net and I am still experiencing the issue even after clearing all temp folders etc. In my YAML can you provide me some help what I need to change to force the version of Nuget ?

      • varunmittal's avatar
        varunmittal
        Copper Contributor
        The error message "The attribute "Version" in element <PackageReference> is unrecognized" suggests that there is a problem with the version of NuGet that is being used. The version of NuGet that is being used is 6.4.0.123, which may be causing an issue with the version of the packages in your project.

        You can try to update NuGet to the latest version by running the following command:
        nuget update -self

        You can also try to specify the version of NuGet to use in the NuGetCommand step in your pipeline yaml file:
        - task: NuGetCommand@2
        inputs:
        restoreSolution: '$(solution)'
        version: 'latest'

        Another thing you can try is to update your dotnet core version to latest version and check if it is compatible with the version of NuGet that you have installed.

        Finally, you can also try to delete the package references and re-adding them, or even try a different package version.

        To force the version of NuGet in your pipeline YAML file, you can add the version input to the NuGetCommand task. For example, if you want to use version 6.5.0 of NuGet, you can update the NuGetCommand task in your pipeline as follows:
        - task: NuGetCommand@2
        inputs:
        restoreSolution: '$(solution)'
        version: '6.5.0'
        This will instruct the pipeline to use version 6.5.0 of NuGet for restoring packages.
        Alternatively, if you want to use the latest version of NuGet, you can specify the version as latest:
        - task: NuGetCommand@2
        inputs:
        restoreSolution: '$(solution)'
        version: 'latest'
        You can check the latest version of NuGet from the official Nuget website, and update the version number accordingly.

        Additionally, you can also try adding the following line in the pipeline to use the nuget.exe in the NuGet tool installer step:
        - task: NuGetCommand@2
        inputs:
        command: restore
        restoreSolution: '$(solution)'
        feedsToUse: 'config'
        nugetConfigPath: '$(NuGetToolInstaller.NuGetConfigPath)'
        It may be helpful to clear the NuGet package cache before.

        To clear the NuGet package cache, you can use the following command in the NuGet Package Manager Console:
        nuget locals all -clear

        This command will clear all the local NuGet package caches, including the packages, http-cache, and temp files.

        You can also use the following command to clear specific NuGet cache:
        nuget locals [cache-name] -clear

        Where [cache-name] can be one of the following:
        packages
        http-cache
        temp
        For example, to clear the packages cache, use the following command:
        nuget locals packages -clear

        Additionally, the NuGet cache can also be found in the following location on your machine:
        Copy code
        %UserProfile%\.nuget\packages
        You can simply delete the contents of this folder.

        some official documentation from NuGet on how to clear the cache and troubleshoot issues:

        https://docs.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders#how-to-clear-the-global-packages-folder
        https://docs.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders
        https://learn.microsoft.com/en-us/nuget/reference/nuget-exe-cli-reference

        Additionally, you can also find more information on NuGet's GitHub page, where you can find other users' issues and solutions, or submit your own:
        https://github.com/NuGet/Home/issues

        Please let me know if you have any other question.



Share

Resources