Team Foundation Service build fails on NuGet package restore

后端 未结 10 1895
半阙折子戏
半阙折子戏 2020-12-13 02:23

I\'m having kind of an odd problem with my Team Foundation Service build. I queue it up and it starts just fine, but then it fails with the following error:



        
相关标签:
10条回答
  • 2020-12-13 03:22

    Problem Story:

    In my case, one of my teammate has used the VisualStudio 2017. There we have downgrade some nuget packages from the project file by writing versions with hands like postsharp etc. It has worked out on there and he pushed the updated code to the gitlab. On my side i have pooled the code from gitlab to my local repo and i have opened it with VisualStudio 2019 and i take this error

    Solution:

    1- I have opened the code with VisualStudio 2017 from my updated local repo and rebuilt it with it.

    2- I have closed the VisualStudio 2017 and reopened with VisualStudio 2019. Rebuild is sucessfull this time

    For all who faced

    0 讨论(0)
  • 2020-12-13 03:23

    If someone still having this issue on tfs build server you need to go the following:

    1. Make sure all projects in solution you attempt to build have the latest Microsoft.Bcl.Build package (just update it in package manager).
    2. After build failed see all project (in tfs build log summary) that generate this error ("The build restored NuGet packages ...")
    3. Open each of those project's .proj file and comment out whole target element started with 'Target Name="EnsureBclBuildImported"'
    4. Check in and retry the build

    It seems somehow after upgrading not all projects get those old block of build code removed and it's causing problems (as I understand it it's not longer needed after microsoft changed their bcl build process).

    0 讨论(0)
  • 2020-12-13 03:24

    I had to restore packages prior to the clean target of my build script. I mistakenly thought restoring packages prior to building was enough.

    <?xml version="1.0" encoding="utf-8"?>
    <Project DefaultTargets='GatherBinaries' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
    
        <Target Name='RestorePackages'>
            <Exec Command='tools\NuGet.exe Restore "Web.sln"'/>
        </Target>
    
        <!--
            must call RestorePackages prior to clean to avoid error the following error
            "The build restored NuGet packages. Build the project again to include these packages in the build."
            -->
        <Target Name='Clean' DependsOnTargets='RestorePackages'>
            <MSBuild Projects='Web.sln' Targets='Clean' Properties='Configuration=Release'/>
        </Target>
    
        <Target Name='Build' DependsOnTargets='Clean;RestorePackages'>
            <MSBuild Projects='Web.sln' Targets='Build' Properties='Configuration=Release'/>
        </Target>
    
    </Project>
    
    0 讨论(0)
  • 2020-12-13 03:26

    The right solution can be found here: https://docs.microsoft.com/ru-ru/nuget/consume-packages/package-restore-troubleshooting

    Just add to NuGet.Config:

    <!-- Package restore is enabled -->
    <configuration>
        <packageRestore>
            <add key="enabled" value="True" />
            <add key="automatic" value="True" />
        </packageRestore>
    </configuration>
    
    0 讨论(0)
提交回复
热议问题