Search code examples
tfsbuildcustom-activity

cancel build based on return value of codeactivity


After migrating to TFS/VS2010 I want to redesign/migrate the build process to the new workflow foundation and codea ctivities.

Some of my code activities are doing some checks against sharepoint and databases and returning a bool if the checks are succeed.

They are executed first, only print out some build detail and dont need any workspace data, so I placed them between the "Initialize Variables" and "Initialize Workspace" sequences.

I am new to workflow foundation so iam struggeling to find a way to let the build cancel (not partially succeeded) based on the return value of the code actvities.


Solution

  • In your code activity, you can just throw an exception with a message indicating why the build fails. This exception will stop the build process and the error you throw will get logged as a build error.

    Hope this helps.