Skip to main content

In order to automate the package and deployment process I used SourceCode.Deployment.Management dll to create the deployment package using the following code: 

Session session = _packageDeploymentManager.CreateSession("K2Module" + DateTime.Now.ToString());                session.SetOption("NoAnalyze", true);                PackageItemOptions options = PackageItemOptions.Create();                options.ValidatePackage = Validate;                var pathNamespace = "/root/";                var rootNamespace = "urn:SourceCode/Categories";                string ns;                string category;                var categories = Category.Split('');                if (categories.Length > 1)                {                    var parentCats = string.Join("/", categories.Take(categories.Length - 1));                    pathNamespace += parentCats + "/";                }                category = categories.Last();                ns = rootNamespace + "?" + Uri.EscapeDataString(category) + "#Path." + Uri.EscapeDataString(pathNamespace);                                var typeRef = new TypeRef(category, ns);                                var query = QueryItemOptions.Create(typeRef);                var results = session.FindItems(query).Result;                foreach (var result in results)                {                    options.Include(result, PackageItemMode.IncludeDependencies);                }                options.PackageItemMode = IncludeDependenciesAsReference ? PackageItemMode.IncludeDependenciesAsReference : PackageItemMode.IncludeDependencies;                session.PackageItems(options);                var fileStream = new FileStream(Path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);                session.Model.Save(fileStream);                fileStream.Close();                _packageDeploymentManager.CloseSession(session.Name);

but I couldn't deploy the genrated package, becuase of error "This version was created on version is no longer suppoerded on this target environment", Actually I'm using K2 five and all dlls I'm using from inside the environment itself.   

Hi Sello,

 

Thanks for your reply, but actually I'm working on K2 five version 5.2 and this solution doesn't work with me.

 

Thanks, 


The environment your package was created on must match the environment the package is being deployed to. Most importantly, they must be on the same version, with the same updates applied.


 


First off, make sure both environment is on the same version.


 


Secondly, check the HostServer.UpdateHistory table on your K2 database. Make sure both environments have the same updates applied.


 


Once you have the above nailed down, you can use the dll from either the source or target environment. It shouldn't matter at this point.


 


Reply