Skip to content
Simple and time-saving Microsoft and Sitecore Commerce Server task automation. Have an easy life!
F# Forth Batchfile
Find file
New pull request
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Simple and time-saving Commerce Server task automation library. Do things like deleting, purging and importing promotions. CsTasks provides a consistent .NET API around existing tools and APIs.


  • Collect useful Commerce Server tools in a single Nuget package (licenses permitting).
    • Consistent, single location makes it easier to share scripts.
    • No need to add tools to source control (as can use Nuget package restore).
    • Get new features and fixes without effort!
  • Provide common administration tasks via a simple, easy to use .NET API.
    • Probably safer than hacking command line scripts.
    • Enable script sharing and re-use.
  • Support scripting from F# and Powershell.
    • Integrate tasks into build and environment scripts.


Get your name here too. Fork and contribute!


  • Import discounts, promotion codes and global expressions.
  • Delete discounts, direct mail and advertisment campaign items.
  • Purge marketing data, baskets, purchase orders and catalog data.

Example - Delete, Purge and Import Discounts

This example does the following:

  • Exports existing discounts to the Temp folder.
  • Deletes all the discounts.
  • Purges the deleted discounts.
  • Deletes all the expressions.
  • Reseeds expression and campaign item ids.
  • Imports discounts, expressions and promo codes from XML.

The code is written as an F# script:

open CsTasks
open System.IO

//Setup our site environment.
let siteName = "StarterSite"
let marketingWebServiceUrl = @"""http://localhost/MarketingWebService/MarketingWebService.asmx""" 
let tempPath = Path.GetTempPath()
let purgeTool = PurgeCommerceDataTool(siteName)
let marketingDataStore = MarketingDataStore(siteName)

//Do a safety export to Temp (using an CsTasks F# function).
ExportDiscounts (fun defaultArgs ->
    { defaultArgs with
        DiscountExportArgs.MarketingWebServiceUrl = marketingWebServiceUrl
        ExportDirectoryPath = tempPath })

//Delete all campaign items.

//Purge marketing data (so we can delete expressions)
let retCode = purgeTool.PurgeAllMarketingData()

//Delete expressions.

//Reseed all Ids so our imported discounts get the same IDs each time.

//Do the discount import.
ImportDiscounts (fun defaultArgs -> { defaultArgs with DiscountImportArgs.MarketingWebServiceUrl = marketingWebServiceUrl})


  • Commerce Server. Version 2007 or greater.


To install CsTasks from run the following command in the Nuget Package Manager Console.

PM> install-package CsTasks

Additional Information

CsTasks uses the following tools and APIs.

CsTasks is written in F# and we use it from .fsx build scripts. However, it is a normal .NET assembly so you can use it from any .NET language.

Known Issues

None. Raise one.

Release Notes


  • More bug fixes for CS10 support :). Code and schema namespace changes are a pain in the butt!


  • Bug fixes for CS10 support.


  • Support for CS10+.
  • Generate two lib assemblies. CsTasks.dll for CS10+ and CsTasksMS.dll for CS2007 and CS2009.


  • Add support for i_SearchResultsLimit so that ALL campaign items are deleted, even when paged.
  • Addition of very basic test discount generator (used for volume testing).


  • New: DeleteAllPromoCodeDefinitions added to MarketingDataStore.


  • Removed CTP extension. No longer a PRE package.
  • Added ReseedCampaignIds to MarketingDataSource.


  • Breaking change: Rolled marketing functions into MarketingDataStore class. Should be easier to use for most.
  • New: Added reseeding for expressions and campaign items.


  • Removed dependency on FAKE.
  • Breaking: Replaced PurgeCommerceDataTool functions with PurgeCommerceDataTool class.



Something went wrong with that request. Please try again.