How to get nuget restore in TFS build

后端 未结 2 1712
别那么骄傲
别那么骄傲 2021-01-21 04:36

I can\'t make it work TFS build. It is nuget restore issue. Nuget is not restoring reference dll files.

Here is belwo my build configuration. Please advise me how I can

相关标签:
2条回答
  • 2021-01-21 05:00

    Here are some steps (described here which was mentioned in Dave's post) you need to follow in order to have these NuGet packages restored during the VSO (TFS) build process.

    1. Add following items to the solution. (Content of the nuget.config and .tfignore file can be found here)

    1. Add one build.proj file under the root path of the solution folder. (Content of the build.proj file can be found here)

    2. Create one folder named tools under the root path of the solution folder. Create NuGet sub-folder under tools folder, download and save nuget.exe under tools\NuGet path.

    3. Check in nuget.config, .tfignore, build.proj and tools\NuGet\nuget.exe into TFS version control.

    4. Modify the build definition to choose to build the build.proj file.

    Then you will have NuGet packages restored successfully during the TFS build process.

    0 讨论(0)
  • 2021-01-21 05:03

    As per this blog post on Nuget's website you can use the command line you mentioned, but it has to be part of a custom target using a Build.proj file.

    You need to add a Build.proj and put this as the contents:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0"
             DefaultTargets="Build"
             xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    
      <PropertyGroup>
        <OutDir Condition=" '$(OutDir)'=='' ">$(MSBuildThisFileDirectory)bin\</OutDir>
        <Configuration Condition=" '$(Configuration)'=='' ">Release</Configuration>
        <SourceHome Condition=" '$(SourceHome)'=='' ">$(MSBuildThisFileDirectory)src\</SourceHome>
        <ToolsHome Condition=" '$(ToolsHome)'=='' ">$(MSBuildThisFileDirectory)tools\</ToolsHome>
      </PropertyGroup>
    
      <ItemGroup>
        <Solution Include="$(SourceHome)*.sln">
          <AdditionalProperties>OutDir=$(OutDir);Configuration=$(Configuration)</AdditionalProperties>
        </Solution>
      </ItemGroup>
    
      <Target Name="RestorePackages">
        <Exec Command="&quot;$(ToolsHome)NuGet\NuGet.exe&quot; restore &quot;%(Solution.Identity)&quot;" />
      </Target>
    
      <Target Name="Clean">
        <MSBuild Targets="Clean"
                 Projects="@(Solution)" />
      </Target>
    
      <Target Name="Build" DependsOnTargets="RestorePackages">
        <MSBuild Targets="Build"
                 Projects="@(Solution)" />
      </Target>
    
      <Target Name="Rebuild" DependsOnTargets="RestorePackages">
        <MSBuild Targets="Rebuild"
                 Projects="@(Solution)" />
      </Target>
    
    </Project>
    

    Alternatively, you could call it from a custom Pre-Build Script.

    Or, customise the XAML template and add a Foreach loop to invoke:

    nuget.exe restore path\to\solution.sln
    

    on each solution in the build definition.

    0 讨论(0)
提交回复
热议问题