2015-10-31 78 views
1

我想在Jenkins中使用MSBuild腳本生成代碼。我的代碼庫在Visual Studio Online上。下面的腳本不會複製本地機器上的輸出文件夾中的任何內容。而如果我在本地機器上使用相同的腳本,它可以正常工作。下面是我使用我的構建腳本:使用MSBuild和Jenkins從Visual Studio Online自動生成

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
<ItemGroup> 
    <BuildArtifactsDir Include="D:\Jenkins\jobs\Test\workspace\BuildArtifacts\"/> 
    <TeamFoundationServerUrl Include="https://XXX.visualstudio.com/DefaultCollection/XXX-XXX/"/> 
    <SolutionFile Include="$(TeamFoundationServerUrl)*.sln"/> 
</ItemGroup> 
<PropertyGroup> 
    <Configuration Condition="'$(Configuration)'=='' ">Release</Configuration> 
    <BuildPlatForm Condition="'$(BuildPlatForm)'=='' ">Any CPU</BuildPlatForm> 
</PropertyGroup> 
<Target Name="Compile" DependsOnTargets="Init"> 
    <MSBuild Projects="@(SolutionFile)" Targets="Rebuild" 
      Properties="OutDir=%(BuildArtifactsDir.FullPath);Configuration=$(Configuration);Platform=$(BuildPlatform)"/> 
</Target> 
<Target Name="Init"> 
    <MakeDir Directories="@(BuildArtifactsDir)"/> 
</Target> 

我的環境:

詹金斯:在我的本地主機。在Jenkins的MSBuild插件。 Visual Studio Online for Code存儲庫。

+0

您如何驗證VSO?以交互方式運行MSBuild,憑證取自Credential Manager存儲,但Jenkins作爲服務運行,可能使用LocalSystem。 –

回答

0

您無法直接通過msbuild從VSO/TFS獲得解決方案。

要從Jenkins連接到VSO/TFS服務器,可以通過「管理詹金斯 - >管理插件 - >可用 - > Team Foundation Server插件」在Jenkins服務器中安裝TFS插件。然後配置您的項目如下: enter image description here 插件將從您的VSO/TFS服務器獲得最新的解決方案並將其複製到您的Jenkins服務器,然後您可以相應地更新您的msbuild腳本。

請注意,您需要使用「備用認證憑證」才能使用此插件登錄VSO/TFS服務器。要啓用此功能,請登錄您的VSO/TFS帳戶,在「我的個人資料/安全/備用身份驗證憑據」下啓用該帳戶。

+0

我之前做過相同的步驟,能夠從VSO獲取最新的代碼,但是我只想從構建(僅.dll,.cshtml,.css,.html,.js文件等.CS文件除外)使用MSBuild的VSP。我可以轉換成使用MSBuild構建。請建議我。 –

+0

我想在Jenkins中使用MSBuild從VSO下載工件。 –

+0

MSBuild只能構建您指定的解決方案並將工件發佈到指定的位置。它不能實現像連接到TFS這樣的操作,複製工件。 –

相關問題