1
我們正在使用VSO和Azure雲服務(Web角色)。VSO和Azure中的持續集成和NuGet恢復
此前,我們已經使用了以下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=""$(MSBuildThisFileDirectory).nuget\NuGet.exe" restore "%(Solution.Identity)"" />
</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>
這樣做的原因是執行的NuGet恢復之前的MSBuild開始運行。這是NuGet的suggested approach。
現在我們正在嘗試與我們的Azure雲服務建立持續集成,如this MSDN article中的說明。
這意味着我們現在必須使用TfvcContinuousDeploymentTemplate.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恢復工作的良好解決方案?