
持續整合 - 構建指令碼
現在我們來看下 MSBuild 檔案的某些方面來了解它們的含義。瞭解這些方面對於持續整合迴圈來說很重要。
構建指令碼用於構建解決方案,這將會是整個持續整合迴圈的一部分。我們來看一看在 Visual Studio 的.Net中建立的構建指令碼,用於我們的示例解決方案。即使對於一個簡單的解決方案來說,構建指令碼都是相當龐大的,因此我們將詳細介紹其中最重要的部分。預設情況下,構建指令碼將儲存在與 Visual Studio 中主解決方案同名的檔案中。因此,在我們的示例中,如果你打開了檔案Simple.csproj,你會看到將用來構建解決方案的所有設定。
依賴於所使用的 MSBuild 版本 - 以下設定將使用 CI 伺服器上安裝的 MSBuild 檔案。
<VisualStudioVersion Condition = "'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> <VSToolsPath Condition = "'$(VSToolsPath)' == ''"> $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) </VSToolsPath> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <Import Project = "$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project = "$(VSToolsPath)\WebApplications\ Microsoft.WebApplication.targets" Condition = "'$(VSToolsPath)' ! = ''" /> <Import Project = "$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\ WebApplications\Microsoft.WebApplication.targets" Condition = "false" />
正確構建解決方案所需的檔案 - ItemGroup 標記將包含讓專案成功構建所需的所有必要的 .Net 檔案。這些檔案需要相應地駐留在構建伺服器上。
<ItemGroup> <Reference Include = "Microsoft.CSharp" /> <Reference Include = "System.Web.DynamicData" /> <Reference Include = "System.Web.Entity" /> <Reference Include = "System.Web.ApplicationServices" /> <Reference Include = "System.ComponentModel.DataAnnotations" /> <Reference Include = "System" /> <Reference Include = "System.Data" /> <Reference Include = "System.Core" /> <Reference Include = "System.Data.DataSetExtensions" /> <Reference Include = "System.Web.Extensions" /> <Reference Include = "System.Xml.Linq" /> <Reference Include = "System.Drawing" /> <Reference Include = "System.Web" /> <Reference Include = "System.Xml" /> <Reference Include = "System.Configuration" /> <Reference Include = "System.Web.Services" /> <Reference Include = "System.EnterpriseServices"/> </ItemGroup>
要使用的 Web 伺服器設定 - 當我們訪問持續部署主題時,你將看到如何使用 MSBuild 覆蓋這些設定並將其部署到我們選擇的伺服器上。
<UseIIS>True</UseIIS> <AutoAssignPort>True</AutoAssignPort> <DevelopmentServerPort>59495</DevelopmentServerPort> <DevelopmentServerVPath>/</DevelopmentServerVPath> <IISUrl></IISUrl> <NTLMAuthentication>False</NTLMAuthentication> <UseCustomServer>False</UseCustomServer>
廣告