1
votes

I want to build the code using MSbuild Script in Jenkins. My code repository is on Visual Studio Online. The below script does not copy anything in the output folder on my local machine. Whereas if I am using the same script on my local machine it works fine. Below is the script I am using for my build:

   <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>

My Environment:

Jenkins: On my local host. MSBuild Plugin in Jenkins. Visual Studio Online for Code repository.

1
How do you authenticate to VSO? Running MSBuild interactively, the credential is taken from Credential Manager store, but Jenkins is running as a service, probably using LocalSystem.Giulio Vian

1 Answers

0
votes

You cannot get the solution from VSO/TFS via msbuild directly.

To connect to VSO/TFS server from Jenkins, you can install TFS Plug-in in your Jenkins server via "Manage Jenkins -> Manage Plugins -> Available -> Team Foundation Server Plug-in". And then configure your project like following: enter image description here The plug-in will get the latest solution from your VSO/TFS server and copy it to your Jenkins server, you can then update your msbuild script accordingly.

Please note that you need to use "Alternate authentication credentials" to log in VSO/TFS server with this plug-in. To enable this feature, sign in your VSO/TFS account, enable it under "My Profile/Security/Alternate authentication credentials".