{"id":1340,"date":"2013-09-30T20:06:45","date_gmt":"2013-09-30T20:06:45","guid":{"rendered":"http:\/\/turtlellc.com\/?p=1340"},"modified":"2017-09-22T19:59:23","modified_gmt":"2017-09-22T19:59:23","slug":"sharepoint-workflow-versioning-with-visual-studio-2012","status":"publish","type":"post","link":"http:\/\/www.turtle.works\/knowledge\/sharepoint-workflow-versioning-with-visual-studio-2012\/","title":{"rendered":"SharePoint Workflow Versioning with Visual Studio 2012"},"content":{"rendered":"<p>I needed a methodology for publishing new versions of SharePoint workflows using Visual Studio. I have a Document Library that has a workflow (we&#8217;ll call it version 1). The document,\u00a0<em>9-30 Staff Meeting.pdf,<\/em> is running workflow version 1; waiting on a user to complete a task. However, I&#8217;ve changed the code and want new documents to run the workflow with the changes (we&#8217;ll call this workflow version 2). Here is the key, while the new document, <em>10-7 Staff Meeting.pdf<\/em>, \u00a0will run workflow version 2, I need the the already in progress,\u00a0<em>9-30 Staff Meeting.pdf<\/em>document,<em>\u00a0<\/em>to complete\u00a0using the existing version 1 assembly.<!--more--><\/p>\n<h1>In a Nutshell<\/h1>\n<ol>\n<li><span style=\"line-height: 13px;\">Deploy Version 1<\/span>\n<ol>\n<li>Add Assembly name suffix of &#8220;_v1&#8221;<\/li>\n<li>Change Assembly version and File version<\/li>\n<li>Add a suffix to the workflow Elements.xml file Name element (&#8220;v1.0.0.0&#8221;)<\/li>\n<li>Rebuild Solution<\/li>\n<li>Publish the Workflow<\/li>\n<li>Add the Solution\n<ol>\n<li><em>Add-SPSolution -LiteralPath C:\\Downloads\\Blog\\C#\\SequentialWorkflow\\bin\\Debug\\SequentialWorkflow.wsp<\/em><\/li>\n<\/ol>\n<\/li>\n<li><span style=\"font-size: 13px;\">Deploy the Solution using Central Administration &gt; System Settings &gt; Manage Farm Solutions<\/span><\/li>\n<li>Activate the Feature<\/li>\n<li>Add the workflow to Shared Documents<\/li>\n<\/ol>\n<\/li>\n<li>Make a Version 2 Workflow\n<ol>\n<li>Copy the version 1 dll to a v1.0.0.0 folder<\/li>\n<li>Change \u00a0Assembly name suffix to _v2<\/li>\n<li>Change Assembly version and File version<\/li>\n<li>Change workflow Elements.xml file &gt; Name element suffix changed to v2.0.0.0<\/li>\n<li>Include version 1 dll in the Package.package\n<ol>\n<li>Source Path: bin\\v1.0.0.0\\SequentialWorkflow_v1.dll<\/li>\n<li>Location: v1.0.0.0\\SequentialWorkflow_v1.dll<\/li>\n<\/ol>\n<\/li>\n<li>Make workflow changes as needed (code and activities)<\/li>\n<li>Rebuild the Solution<\/li>\n<li>Publish the workflow project, replacing the existing .wsp file<\/li>\n<li>Update the Solution\n<ol>\n<li>Update-SPSolution -Identity SequentialWorkflow.wsp -LiteralPath C:\\&lt;my path&gt;\\bin\\Debug\\SequentialWorkflow.wsp -GACDeployment<\/li>\n<\/ol>\n<\/li>\n<li>Add the workflow to Shared Documents<\/li>\n<li>Allow <em>No New Instances<\/em> of the version 1 workflow<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<h1><\/h1>\n<h1>Versioning In Detail<\/h1>\n<h2>Deploy Version 1<\/h2>\n<p>To achieve this follow the below method:<\/p>\n<ol>\n<li><span style=\"font-size: 13px;\">Set the workflow assembly\u00a0version to 1.0.0.0<\/span>\n<ol>\n<li><span style=\"font-size: 13px;\">Display the properties of the workflow project in Visual Studio<\/span><\/li>\n<li><span style=\"font-size: 13px;\">Add a version suffix to the Assembly name<\/span><\/li>\n<li><span style=\"font-size: 13px;\">Ensure the Assembly version and File version are set to 1.0.0.0<br \/>\n<a href=\"http:\/\/turtlellc.com\/wp-content\/uploads\/2013\/09\/Assembly1.0.0.0.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1341\" src=\"http:\/\/turtlellc.com\/wp-content\/uploads\/2013\/09\/Assembly1.0.0.0.png\" alt=\"Assembly 1.0.0.0\" width=\"569\" height=\"566\" \/><\/a><br \/>\n<\/span><\/li>\n<li>Add a suffix to the workflow Name in the workflow Elements.xml file<a href=\"http:\/\/turtlellc.com\/wp-content\/uploads\/2013\/09\/Elementsv1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1342\" src=\"http:\/\/turtlellc.com\/wp-content\/uploads\/2013\/09\/Elementsv1.png\" alt=\"Elementsv1\" width=\"433\" height=\"56\" \/><\/a><\/li>\n<li>Rebuild the Solution<\/li>\n<li>Publish the workflow by right clicking the workflow project in Solution Explorer and clicking Publish&#8230;<\/li>\n<li><span style=\"font-size: 13px;\">In this case, I&#8217;m publishing to the Debug folder<br \/>\n<a href=\"http:\/\/turtlellc.com\/wp-content\/uploads\/2013\/09\/Publish1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1343\" src=\"http:\/\/turtlellc.com\/wp-content\/uploads\/2013\/09\/Publish1.png\" alt=\"Publish1\" width=\"457\" height=\"278\" \/><\/a><\/span><\/li>\n<li><span style=\"font-size: 13px;\">Add the Solution to SharePoint: In the SharePoint 2010 Management Shell type <em>Add-SPSolution -LiteralPath C:\\Downloads\\Blog\\C#\\SequentialWorkflow\\bin\\Debug\\SequentialWorkflow.wsp<\/em><\/span><\/li>\n<li><span style=\"font-size: 13px;\">Deploy the Solution:\u00a0<\/span>\n<ol>\n<li><span style=\"font-size: 13px;\">Open Central Administration &gt; System Settings &gt; Manage Farm Solutions<\/span><\/li>\n<li>Click on sequentialworkflow.wsp<\/li>\n<li>Click Deploy Solution<\/li>\n<li>Click OK, noticing that it will deploy, Now, and it is using the GAC<br \/>\n<a href=\"http:\/\/turtlellc.com\/wp-content\/uploads\/2013\/09\/Deploy1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1344\" src=\"http:\/\/turtlellc.com\/wp-content\/uploads\/2013\/09\/Deploy1.png\" alt=\"Deploy1\" width=\"408\" height=\"485\" \/><\/a><\/li>\n<\/ol>\n<\/li>\n<li>Activate the Feature\n<ol>\n<li>Site Settings &gt; Go to top level site settings (if necessary)<\/li>\n<li>Site Collection Features<\/li>\n<li>Click the Activate button if necessary for SequentialWorkflow Feature1<\/li>\n<\/ol>\n<\/li>\n<li>Add the workflow to Shared Documents\n<ol>\n<li>Shared Documents &gt; Library &gt; Workflow Settings<\/li>\n<li>Click Add a workflow\n<ol>\n<li>Select\u00a0<em>SequentialWorkflow &#8211; Workflow v1.0.0.0<\/em><\/li>\n<li>Give it a unique name: SequentialWorkflow v1<\/li>\n<li>Click OK<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<h2>Test Version 1<\/h2>\n<p>To test the version 1 workflow:<\/p>\n<ol>\n<li><span style=\"line-height: 13px;\">Add a couple document to Shared Documents<\/span><\/li>\n<li>Run the <em>SequentialWorkflow v1<\/em> workflow against that document<\/li>\n<li>View the Workflow Information to see the pending task<\/li>\n<li>Edit the task, setting Status to Completed and % Complete to 100<\/li>\n<li>Save the task<\/li>\n<li>Notice the Workflow History shows a Description of Workflow Version 1 completed<\/li>\n<\/ol>\n<p>Run the SequentialWorkflow v1 workflow against a document again, but do not complete the task. We need this running, so we can test version 2 of the workflow further below in this post.<\/p>\n<h2>Make a Version 2 Workflow<\/h2>\n<ol>\n<li><span style=\"line-height: 13px;\">Save the version 1 dll<\/span>\n<ol>\n<li>In the &lt;project&gt;\\bin folder create a new folder called v1.0.0.0<\/li>\n<li>Copy the SequentialWorkflow_v1.dll to the folder<br \/>\n<a href=\"http:\/\/turtlellc.com\/wp-content\/uploads\/2013\/09\/dll1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1345\" src=\"http:\/\/turtlellc.com\/wp-content\/uploads\/2013\/09\/dll1.png\" alt=\"dll1\" width=\"308\" height=\"126\" \/><\/a><\/li>\n<\/ol>\n<\/li>\n<li>Using steps 1 thru 4 in the Deploy Version 1 section above, set the version of the workflow assembly to 2.0.0.0<\/li>\n<li>Include the version 1 dll in the new solution\n<ol>\n<li>Solution Explorer &gt; Package<\/li>\n<li>Double click Package.package<\/li>\n<li>Click the Advanced tab<\/li>\n<li>Add &gt; Add exiting assembly<\/li>\n<li>Browse to the v1.0.0.0 folder where you saved the SequentialWorkflow_v1.dll file, select it and click Open<\/li>\n<li>Add a v1.0.0.0\\ prefix to the Location<br \/>\n<a href=\"http:\/\/turtlellc.com\/wp-content\/uploads\/2013\/09\/AddAssembly1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1346\" src=\"http:\/\/turtlellc.com\/wp-content\/uploads\/2013\/09\/AddAssembly1.png\" alt=\"AddAssembly1\" width=\"455\" height=\"156\" \/><\/a><\/li>\n<li>Click OK<\/li>\n<\/ol>\n<\/li>\n<li>Modify the workflow code as needed for version 2. In this example I change my logging statement to say &#8220;Workflow Version 2 completed&#8221;<\/li>\n<li>Rebuild the Solution<\/li>\n<li>Publish the SequentialWorkflow project replacing the existing .wsp file<\/li>\n<li>Using the SharePoint 2010 Management Shell update the Solution: Update-SPSolution -Identity SequentialWorkflow.wsp -LiteralPath C:\\&lt;my path&gt;\\bin\\Debug\\SequentialWorkflow.wsp -GACDeployment<\/li>\n<li>Add the workflow to Shared Documents. See step 11 in Deploy Version 1<\/li>\n<li>Allow <em>No New Instances<\/em> of the version 1 workflow\n<ol>\n<li>Document Library Settings &gt; Workflow Settings<\/li>\n<li>Click Remove a workflow<\/li>\n<li>Set SequentialWorkflow v1 to No New Instances<br \/>\n<a href=\"http:\/\/turtlellc.com\/wp-content\/uploads\/2013\/09\/NoNewInstances.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1347\" src=\"http:\/\/turtlellc.com\/wp-content\/uploads\/2013\/09\/NoNewInstances.png\" alt=\"NoNewInstances\" width=\"473\" height=\"80\" \/><\/a><\/li>\n<li>Click OK<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<h2>Test Version 2<\/h2>\n<p>To test the version 1 workflow:<\/p>\n<ol>\n<li>Make sure you have a <em>SequentialWorkflow v1<\/em> workflow <em>In Progress<\/em><\/li>\n<li>Run the\u00a0<em>SequentialWorkflow v2<\/em>\u00a0workflow against a different document<\/li>\n<li>View the Workflow Information to see the pending task<\/li>\n<li>Edit the task, setting Status to Completed and % Complete to 100<\/li>\n<li>Save the task<\/li>\n<li>Notice the Workflow History shows a Description of <em>Workflow Version 2 completed<\/em><\/li>\n<li>Complete the task for In Progress <em>SequentialWorkflow v1<\/em> workflow<\/li>\n<li>Notice the Workflow History shows a Description <em>Workflow Version 1 completed<\/em><\/li>\n<\/ol>\n<p>Thanks to Raghavendra B Nanjaiah at Microsoft for help with this.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I needed a methodology for publishing new versions of SharePoint workflows using Visual Studio. I have a Document Library that has a workflow (we&#8217;ll call it version 1). The document,\u00a09-30 Staff Meeting.pdf, is running workflow version 1; waiting on a user to complete a task. However, I&#8217;ve changed the code and want new documents to &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.turtle.works\/knowledge\/sharepoint-workflow-versioning-with-visual-studio-2012\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;SharePoint Workflow Versioning with Visual Studio 2012&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-1340","post","type-post","status-publish","format-standard","hentry","category-sharepoint"],"_links":{"self":[{"href":"http:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/posts\/1340","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/comments?post=1340"}],"version-history":[{"count":1,"href":"http:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/posts\/1340\/revisions"}],"predecessor-version":[{"id":1709,"href":"http:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/posts\/1340\/revisions\/1709"}],"wp:attachment":[{"href":"http:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/media?parent=1340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/categories?post=1340"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/tags?post=1340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}