【发布时间】:2015-11-16 10:49:08
【问题描述】:
【问题讨论】:
标签: c# continuous-integration tfsbuild continuous-deployment
【问题讨论】:
标签: c# continuous-integration tfsbuild continuous-deployment
根据 Nuget 网站上的 this blog post,您可以使用您提到的命令行,但它必须是使用 Build.proj 文件的自定义目标的一部分。
您需要添加一个Build.proj 并将其作为内容:
<?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=""$(ToolsHome)NuGet\NuGet.exe" restore "%(Solution.Identity)"" />
</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>
或者,您可以通过custom Pre-Build Script 调用它。
或者,customise the XAML template 并添加一个 Foreach 循环来调用:
nuget.exe restore path\to\solution.sln
在构建定义中的每个解决方案上。
【讨论】:
为了在 VSO (TFS) 构建过程中恢复这些 NuGet 包,您需要遵循以下步骤(在 Dave 的帖子中提到了 here)。
在解决方案文件夹的根路径下添加一个 build.proj 文件。 (build.proj文件的内容可以在here找到)
在解决方案文件夹的根路径下创建一个名为tools的文件夹。在tools文件夹下创建NuGet子文件夹,下载并保存在tools\NuGet路径下nuget.exe。
签入 nuget.config、.tfignore、build.proj 和 tools\NuGet\nuget.exe 进入 TFS 版本控制。
然后您将在 TFS 构建过程中成功恢复 NuGet 包。
【讨论】: