TFS 2013 Build Controller Not Respecting NuGet Package Restore

后端 未结 2 1223
花落未央
花落未央 2021-01-18 00:59

We are using VSO with an on-prem build controller (TFS 2013). I\'ve enabled NuGet package restore in the Options menu of Visual Studio (migrated away from the old, deprecat

相关标签:
2条回答
  • 2021-01-18 01:32

    To enable restore NuGet package with TFS build, please follow steps below. Check this blog for the details.

    1. In VS IDE, go to Tools -> Options -> NuGet Package Manager -> enable Allow NuGet to download missing packages.
    2. Delete NuGet.exe and NuGet.targets files from .nuget folder. Be these two files are deleted from version control as well.
    3. Remove the following tags from .proj file:

        1. <RestorePackages>true</RestorePackages>
    
        2.<Import Project="$(SolutionDir)\.nuget\nuget.targets" />  
    
        3. <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">  
            <PropertyGroup>
                <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, 
        see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
            </PropertyGroup>
            <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
        </Target>

    For your another issue about can't find the TfvcTemplate.12.xaml process template, you can first create a new team project in VSO, download the process file and check it in to Version Control. Then edit the build definition, click the New button on the Process tab, browse the process file in the version control.

    0 讨论(0)
  • 2021-01-18 01:51

    For anyone who stumbles here with the issue I had (some but not all packages being restored on a build server), the final piece of the puzzle for me was adding a NuGet.config in the root of my solution, sibling to the .SLN file as David Ebbo explained here: http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html.

    From Ebbo's blog post, the file contents for me are simply

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <packageSources>
        <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
      </packageSources>
    </configuration>
    

    Sadly, I don't understand why that changed things for me. But it's working now and I'm moving on!

    UPDATE:

    The NuGet API URL has changed for v3 (current as of Sept 2016). From https://www.nuget.org/

    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    
    0 讨论(0)
提交回复
热议问题