Programatically updating process references

  • 19 July 2011
  • 1 reply
  • 0 views

Badge +2


I have a bunch of .kprx files with process references to custom .dlls. When I want to refresh the reference, I have to go an manually remove the reference and complete the reference wizard. Then go back and re-add the reference and complete the wizard again. 


That is a pain, so I'd like to do this programmatically. I wrote the code below which does seem to update the kprx file, but my references are not refreshing. Any thoughts?


using System;


using System.Collections.Generic;


using System.Linq;


using System.Text;


using SourceCode.Workflow.Authoring;


using SourceCode.ProjectSystem;


using System.IO;


 


namespace Test.K2.ProcessReferenceUpdater


{


    public class Program


    {


        static void Main(string[] args)


        {


            if (args[0] != null)


            {


                //Get Project File


                Process process = SourceCode.Workflow.Authoring.Process.Load(args[0]);


                //Open References and build list


                List<Reference> refsToRemove = new List<Reference>();


                foreach (Reference reference in process.References)
               {


                    refsToRemove.Add(reference);


                }


                //Remove all refs


                foreach (Reference reference in refsToRemove)


                {


                    process.References.Remove(reference);


                }


                process.Save();


                //Add all references back


                foreach (Reference reference in refsToRemove)


                {


                    AssemblyReference newRef = new AssemblyReference(reference.Path);


                    process.References.Add(newRef);


                }


                process.Save();


            }


 


 


 


        }


    }


}




1 reply

Badge

Hi Kim,


Please follow this link-> http://cyclops.nettrends.nl/blog/2008/10/807-released-references-changed/


Can try similar thing, hope it works.


Cheers,


Vivek

Reply