Have a question? Want to report an issue?Contact JFrog support

Skip to end of metadata
Go to start of metadata

Overview

Artifactory brings Continuous Integration to MSBuild, TFS and Visual Studio through the MSBuild Artifactory Plugin. This allows you to capture information about deployed artifacts, resolve Nuget dependencies and environment data associated with MSBuild build runs, and deploy artifacts to Artifactory. In addition, the exhaustive build information captured by Artifactory enables fully traceable builds.

MSBuild Artifactory Plugin

The MSBuild Artifactory plugin is anopen source project on GitHubwhich you can freely browse and fork.

Sample code

To get yourself started,here is an exampleof a solution with multiple projects that use the MSBuild Artifactory Plugin

The MSBuild Artifactory Plugin can be used whether you are running standalone builds or using a CI server. In either case, you should note the following points:

  1. Standalone Integration
    The MSBuild Artifactory Plugin fully integrates with the MSBuild process, so it can run as part of a standard build.
    The plugin uses a conventional MSBuild XML configuration file to influence different stages of the build process.
  2. CI Server Integration
    When running MSBuild builds in your continuous integration server, using the plugin is transparent since it is effectively an integral part of the MSBuild process. The only difference is that the plugin collects information from the CI server.
    The MSBuild Artifactory Plugin fully supports TFS and collects exhaustive build information to enable fully traceable builds. Support for additional CI servers such asJenkins, TeamCity and Bamboo is partial, and the build information collected when running with these tools is correspondingly partial.

Page Contents


Installation

The MSBuild Artifactory Plugin is installed as a "Project Template" using Visual Studio as follows:

  • UnderTools, chooseExtensions and Updates..., select theVisual Studio Gallerysource under theOnlinesection,and run a search for "Artifactory".
  • SelectArtifactoryTemplate Packageextension found, and clickInstall.

  • Once the installation is complete, select theSolutioninto which you want to install the plugin. right-click the solution node and selectAdd|New Project....SelectArtifactoryand click OK.

Creating Artifactory project

ToresolveNugetdependencies, the plugin requires a.nugetdirectory within your Solution. Before you start installation, make sure that this directory exists.

You should see the following changes to your Solution:

  • A new custom project linked to the Artifactory plugin.
  • A.artifactoryfolder is added to your Solution. Make sure this directory is committed to source control.
  • Under the.artifactoryfolder, anArtifactory.buildfile is created. This is the main plugin configuration file.
  • Two.targetsfiles are created. These are used internally by the plugin and should not be modified manually.

  • NewNugetpackages related to the plugin should have been installed into the Solution.
  • The plugin also imports its own MSBuild configuration file to theartifactory.csprojand.nuget\NuGet.targetsfiles in order to be added to the MSBuild process.

The last step will be to link your relevant projects to the Artifactory project via the addedProject Reference. Only the linked projects will be monitor by the plugin.

Installing plugin dependencies

The following two dependencies:Nuget.core v2.8.2andMicrosoft.Web.Xdt v2.1.1must also be installed together with the plugin.

If you are installing the plugin from an instance of Artifactory, you need to ensure that Artifactory has access to the plugin and its dependencies. For example, you might have a virtual repository that references a local repository containing the plugin, and a remote repository that references nuget.org. For more details on configuring Artifactory, please refer toNuGet Repositories.


Update

To update Artifactory extensions, execute the following steps:

  • UnderTools, selectExtensions and Updates..., and then, the "Visual Studio Gallery" source under theUpdatessection.
  • Select theArtifactoryTemplate Packageextension found, and clickUpdate.

Existing Project (Optional Step)

If you alreadyhave anexisting Artifactory project template in your solution, and you want to update it to the latest one, execute the following steps:

  • Right-click on the Artifactory project andselectManage NuGet Packages...
  • In theManage NuGet Packageswindow, select a source (e.g. nuget.org) under theUpdatessection.
  • Select theArtifactorypackage found, and clickUpdate.


Uninstalling

  • Remove the.artifactoryfolder and its contents from the solution.
  • Remove the custom Artifactory project from the solution.

Make sure to delete the items from the file system also.


Migration from the old plugin implementation

To migrate from the old plugin implementation, you need to uninstall it and then install the new implementation


Configuration

General Information

The MSBuild Artifactory Plugin is configured in theArtifactory.buildconfiguration file. The file is structured usingMSBuildlanguage conventions, so all the properties can be externally overridden usingReserved PropertiesorEnvironment Properties.

MSBuild can collect properties that were configured in the buildscope, or in the Environment Variables. This ability can be helpful in different cases:

  • You can dynamically override the plugin configuration according to the build context that it runs in.
  • You can prevent sensitive information from being checked into source control.
    例如,如果构建运行下一个构建服务r such as TFS, all the Artifactory credentials can be defined by the server administrator, and will therefore, not be Checked in/Committed to source control.

For more information about MSBuild properties, please refer to theMSBuild Reference Documentation.

Configuration Instructions

For more details on configuration, please refer to theArtifactory.build configuration file.

Resolution

To resolve packages, the MSBuild Artifactory Plugin uses theNuGet Package Restorefeature with theMSBuild-Integrated Package Restoreapproach. To support this, the project that installed the plugin must be a part of a solution with the.nugetfolder. If the.nugetfolder is absent, the plugin will not override the Package Restore in the solution.

MSBuild-Integrated Package Restore approach

Please note the following points:

  • Even though the plugin is installed on a project level, it overrides the NuGet resolution onallthe projects under the same solution.
  • Manual configuration in the.nuget/NuGet.Configfile is ignored by the plugin.
  • Modifying the.nuget/NuGet.targetsfile can cause unexpected behavior in the resolution process. We strongly recommend that you do not modify these files manually.
  • The.nugetfolder must be committed to source control.

Ensuring package resolution through Artifactory

In order to mitigate situations in which a network connection is not available, the NuGet client locally caches any artifacts downloaded from a remote repository in theNuGet Local Cache(under%AppData%\Local\NuGet\Cache).Subsequently,the NuGet clientfirst checks the cache when trying to resolve packages. Therefore, artifacts downloaded from a remote repository in Artifactory or from the NuGet Gallery, typically get stored in this local cache and will be provided from the cache next time you try to reference them.

To ensure that the NuGet client resolves packages through Artifactory, you need to delete the NuGet Local Cache.

Deployment

In order to support a wide variety of project templates, solution structures and artifact types, the MSBuild Artifactory Plugin is designed to be very flexible and allows the user great freedom in configuring how to deploy packages.

  • Using anInput Pattern,the user can specify the path to files that the plugin will collect for deployment. The path isrelativeto the project in which the plugin is installed, and to other projects referenced by it in the solution.
  • Using anOutput Pattern, the user can specify a deployment path in Artifactory that corresponds to the specifiedInput Pattern.
  • The user can also specifyCustomPropertiesthat should annotate all the artifacts resulting from the specifiedInput Pattern.

Target repository layout

You may define a custom layout for your target repository, but it is up to you to specify the right Output Pattern to ensure that your artifacts are deployed to the right location within the repository. For more details, please refer toLocal Repositories.

Checksum Deployment

To support Artifactory's"Once-And-Only-Once" Content Storage, the plugin efficiently deploys packages to Artifactory using Checksum Deployment. Before an artifact is actually deployed, the plugin passes its checksum to Artifactory.

如果包裹已经存在然后Artifactory does not accept a new copy, it just creates a new metadata entry in the database to indicate that another "copy" of the artifact exists in specified deployment path.

Project-specific Deployment

TheArtifactory.buildfile under the.artifactorydirectory applies to all projects within the solution. However, you can override the deployment configuration for a specific project providing anArtifactory.buildfile within the project scope.For example, you could use this to specify the full path of an artifact that needs to be deployed.The plugin detects the project-specificArtifactory.buildfile and applies the deployment configuration to that project, overriding the general deployment configuration. The example below shows the "ArtifactoryDemo.DAL" project with its ownArtifactory.buildfile to overide the general solution deployment configuration.

Overriding the general solution deployment configuration

Environment Variables

You can enable theEnvironmentVariablestag so that MSBuild Artifactory Plugin uses all environment variables accessible by the build process and registers them in the build info. If running under a build server, the server's properties also used and registered. You may defineIncludePatternsandExcludePatternsto control which variables are included in the published build info.

Pattern wildcards

A patternmay contain the * and the ? wildcards.Include patterns are applied before exclude patterns.

Extensive build information may slow down deployment

Including all environment variables as part of the captured build information may result in very large build objects which in turn, may slow down deployment.

License Control

MSBuild Artifactory Plugin supports Artifactory ProLicense Control. This feature is controlled by several tags in theArtifactory.buildconfiguration file.

LicenseControl
启用或禁用许可控制特性
LicenseViolationRecipients
Specifies addresses of recipients that should receive license alerts by email
AutomaticLicenseDiscovery

When set, Artifactory will analyze and tag the build's dependencies with license information upon deployment

Resource intensive

Automatic license discovery is a resource intensive operation which may slow down deployment. If you do not run automatic license discovery, you can still attach license information manuallyby running 'Auto-Find'

from the build'sLicensestab in the Artifactory UI. For more details, please refer toExamining Build Licenses.

IncludePublishedArtifacts
License checks are usually only run on the dependencies of the published package. If this flag is set, a license check is run on the deployed artifact itself (only valid for NuGet packages)
ScopesForLicenseAnalysis
勒ts you specify the scopes on which license analysis should be run.

Black Duck Code Center Integration

If you are using Artifactory Pro and have an account withBlack DuckCode Center, you can run the build through an automated, non-invasive, open source component approval process, and monitor for security vulnerabilities.

BlackDuckComplianceCheck
启用或禁用许可控制特性
CodeCenterApplicationName
The existing Black Duck Code Center application name
CodeCenterApplicationVersion
The existing Black Duck Code Center application version
LicenseViolationRecipients
Specifies addresses of recipients that should receive license alerts by email
ScopesForLicenseAnalysis
勒ts you specify the scopes on which license analysis should be run.
IncludePublishedArtifacts
License checks are usually only run on the dependencies of the published package. If this flag is set, a license check is run on the deployed artifact itself (only valid for NuGet packages)
AutoCreateMissingComponent
汽车黑鸭子代码中创建缺失的组件Center application after the build is completed and deployed in Artifactory.
AutoDiscardStaleComponent
Auto discard stale components in Black Duck Code Center application after the build is completed and deployed in Artifactory.

Network Configuration

Deploying via Proxy

MSBuild Artifactory Plugin supports deployments via your network proxy. If the values in theProxySettingstag of theArtifactory.buildconfiguration file are not recognized by the plugin, it will fall back to using thehttp_proxyEnvironment Variables for proxy configuration using the formathttp://:@proxy.com.

You can bypass the proxy by setting theBypasstagin the plugin configuration.

Resolution Proxy

Due to atechnical issue in the Nuget Client, you cannot configure the NuGet client for resolution via a proxy through the plugin. Forthe Nuget client to resolve artifacts via a proxy, you need to configure the proxy settings in%APPDATA%\NuGet\NuGet.Config.

For more information on how to configure a Nuget proxy, please refer toNuGet Config Settings.


Running a build with MSBuild Artifactory Plugin

Once you have completed setting up the MSBuild Artifactory Plugin, you can run a project build. The plugin takes effect at the end of the build and does the following:

  1. Publishes the specified published artifacts to the selected target repository and applies the proper path mappings.
  2. Deploys the BuildInfo to Artifactory, providingfull traceability of the build, with links back to the build in TFS.

The example below showsVisual Studio output of a build log (minimumverbositylog level: Normal) with some deployed artifacts. At the bottom there is a link to the Build Info report on Artifactory.


Team Foundation Server (TFS) Integration

MSBuild Artifactory Plugin brings CI Build Integration to TFS users allowing you to efficiently deploy your artifacts to Artifactory. In addition to the BuildInfo that the plugin already registers, all parameters associated with TFS are also recorded to facilitate fully traceable builds.

For more information about how build information is used in Artifactory, please refer toBuildInfo.

MSBuild Arguments in TFS

The MSBuild Artifactory Plugin configuration file supports MSBuildReserved PropertiesorEnvironment Properties,and the best practice is to define these properties in the TFS build configuration. This lets you protect sensitive information and run the same build with different properties. Below is an example of properties configured in the TFS build definition.

Package Restore with Team Foundation Build

For Team Foundation Build 2013 on-premises, the default Build Process Templates already implement theNuGet Package Restore Workflowwithout any special configuration.

To avoid NuGet Package Restore from outside the plugin, you need to remove it from the workflow.


License

The MSBuild Artifactory plugin is available under theApache v2 License.


Screencast


Changelog

2.2.0 (10 Mar 2016)
  1. Support for TFS 2015
2.1.0 (18 Aug 2015)
  1. Support for Visual Studio 2015
  2. Bug fixMSBAI-7
2.0.0 (30 Apr 2015)
  1. Artifactory plugin as aVisual Studio Extension, and used as a "Project template" in the solution.
  2. SupportingBlack DuckCode Center as part of the build process.
1.0.0 (30 Sep 2014)
  1. First release version.

  • No labels