Skip to main content
Nintex Community Menu Bar

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.   

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.


 


Please let us know if you were able to resolve this and how... Automating deployments is often a hot topic in the community and I'd like to hear some success stories in this area.


Hi Tbyrne777,

 

I recently run into the same problem, when I am following the https://dudelisdev.com/2018/02/k2-continuous-integration-part-1.html to create a K2-CI build.

 

For us, it turns out that the issue is causing by a space in our catetory name. The program only creates an almost empty package (2kb) as it doesn't like the space. But the New-K2Package cmdlet doesn't thrown any error. The error you are experiencing is actually from the Write-DeploymentConfig cmdlet.

 

Hope this helps you.

 

Cheers,

Chris


Reply