ARTIFACTORY: How to run MSBuild with TeamCity and integrate the build to Artifactory?

AuthorFullName__c
Yonatan Hen
articleNumber
000005938
FirstPublishedDate
2023-12-13T16:43:50Z
lastModifiedDate
2025-07-20

ARTIFACTORY: How to run MSBuild with TeamCity and integrate the build to Artifactory?

MSBuild build step has been deprecated from TeamCity so to run an MSBuild step that publishes the binaries and build info to Artifactory, we need to run the MSBuild in a different approach.

In the usage example below, we will demonstrate how to handle the deprecation issue by performing a workaround. We will run  MSBuild as a PowerShell build step, utilizing JFrog’s MSBuild project example with JFrog CLI commands in Windows server, with TeamCity version 2023.05.4, to successfully build and upload the MsbuildLibrary content as follows:

  1. Create a repository as mentioned in the project example readme (called “msbuild-local” in this example).
  2. Create a build in TeamCity with a “PowerShell” step.
  3. Configure your instance to work with JFrog CLI from the Windows server. 
  4. Create a PowerShell Script, and specify the JFrog CLI executable path (jf.exe). As an example:
Write-Host "Configure the server to work with CLI"

PATH_TO_CLI_EXECUTABLE\jf.exe c add --url http://ARTIFACTORY_HOSTNAME--user username --password password --insecure-tls=<false/true> --interactive=false

PATH_TO_CLI_EXECUTABLE\jf.exe c use Default-Server

Write-Host "Building the MsbuildLibrary"

cd PATH_TO_THE_MSBUILDLIBRARY\MsbuildLibrary 

msbuild /t:build 

Write-Host "Publishing build info"

msbuild /p:ArtifactoryPublish=true /p:BuildName=someBuildName /p:BuildNumber=10

5. Specifying the jf.exe path in the .csproj files is also required. For example:
 <Target Name="UploadArtifacts" AfterTargets="AfterBuild" Condition=" '$(ArtifactoryPublish)' == 'true' ">
    <Exec Command="PATH_TO_CLI_EXECUTABLE\jf.exe rt upload $(ArtifatsPatternPath) msbuild-local/someBuildName/ --flat=false --build-name=someBuildName --build-number=10"/>
  </Target>


After running the build step, the artifacts and the build info are published to Artifactory:

User-added image
 

Build info content from the example above:

{
    "version": "1.0.1",
    "name": "someBuildName",
    "number": "10",
    "buildAgent": {
        "name": "GENERIC",
        "version": "2.51.1"
    },
    "agent": {
        "name": "jfrog-cli-go",
        "version": "2.51.1"
    },
    "started": "2023-11-23T11:14:32.083+0000",
    "durationMillis": 0,
    "artifactoryPrincipal": "admin",
    "modules": [{
        "properties": {},
        "type": "generic",
        "id": "someBuildName",
        "artifacts": [{
            "type": "dll",
            "sha1": "90d161fc146e5fbd39ec74e8ef814ef70f4a63ad",
            "sha256": "6648b273fee5235f97d05c59aa0fff4e746ce64a2b052071ec9be4da7eaca5d9",
            "md5": "d6045eef506aa817f3d3752fd041343d",
            "name": "MsbuildLibrary.dll",
            "path": "someBuildName/bin/Debug/MsbuildLibrary.dll"
        }, {
            "type": "pdb",
            "sha1": "fc442a8b0d657afaa5af6f1597e6b037f5e98934",
            "sha256": "0e0e109a5cc49e34c5c98927c625240f4998f1256289ac604d9d199960c3e9a7",
            "md5": "a026d42540fe211fdd43cf579cbf0a0b",
            "name": "MsbuildLibrary.pdb",
            "path": "someBuildName/bin/Debug/MsbuildLibrary.pdb"
        }]
    }]
}


The workaround above is suggested as currently the integration of MSBuild and .NET steps is not supported by the Artifactory TeamCity plugin.