azure - VSO 和 Azure 中的持续集成和 NuGet 恢复

标签 azure msbuild nuget azure-web-roles build-definition

我们正在使用 VSO 和 Azure 云服务(Web 角色)。

之前,我们使用以下 build.proj 文件作为 VSO 构建定义:

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

原因是在 MSBuild 开始运行之前执行 NuGet 恢复。这是suggested approach由 NuGet 提供。

现在,我们正在尝试设置与 Azure 云服务的持续集成,如 this MSDN article 中的说明。 .

这意味着我们现在必须使用 TfvcContinouslyDeploymentTemplate.12.xml 构建流程模板。

但是在设置模板构建build.proj文件时,出现以下构建错误:

Exception Message: Deploying to Azure Cloud Service requires a Visual Studio Solution (.sln) that contains either a ccproj or a lsxproj. (type DeploymentException)
Exception Stack Trace:    at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
   at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

使用.sln时,一切正常。但我们显然还需要在构建之前进行 NuGet 恢复。

让持续集成和 NuGet 恢复同时工作的良好解决方案是什么?

最佳答案

我刚刚了解到这是多余的。没有理由手动执行 NuGet 恢复,因为它已内置于 VSO/TFS 中。

了解更多 here .

关于azure - VSO 和 Azure 中的持续集成和 NuGet 恢复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29936135/

相关文章:

visual-studio - 有没有一种干净的方法可以从我的项目中删除 SignalR Javascript 包,但保留 .net DLL?

node.js - Azure Web 部署不显示网页

Azure:具有唯一键的循环(环)队列

TFS CI 构建 - 构建成功后更新自定义定义变量

tfs - 如何定位没有特定标签的 TFS 构建代理?

.net-core - 如何在 Azure Pipelines (VSTS) 构建任务中安装和使用 dotnet 核心工具 (CLI)?

azure - 如何将 Ember CLI 应用程序部署到 Azure 网站

asp.net - "Dependency could not be resolved"将 ASP.NET 5 网站部署到 Azure

tfs - Visual Studio Team Services 构建无法找到库

nuget - 如何使用托管项目中的 native NuGet 包?