After some time, you will have multiple solutions in your CRM environment. In my case, there were multiple unmanaged solutions, as I have transferred many customizations between my test- and productive environment.
Via the solution menu in the settings, you can delete unused solutions, but only one after each other. This consumes much time and therefore I wrote a tool to delete unmanaged solutions, which were modified more than 1 month ago.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
XmlConfigurator.Configure(); _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); using (var orgService = new CrmServiceClient(Connection)) // creating the client { var query = new QueryExpression // creating the query { EntityName = "solution", // entity is solution ColumnSet = new ColumnSet("uniquename"), Criteria = new FilterExpression { Conditions = { new ConditionExpression("ismanaged", ConditionOperator.Equal, false), // only getting unmanaged solutions new ConditionExpression("isvisible", ConditionOperator.Equal, true), // only get visible solutions new ConditionExpression("uniquename", ConditionOperator.NotEqual, "Default"), // exclude the default solution, which is also marked as unmanaged new ConditionExpression("modifiedon", ConditionOperator.LessThan, DateTime.Now.AddMonths(-1)) // getting all solution, modified more than 1 month ago } } }; var result = new ConcurrentBag<Entity>(orgService.RetrieveMultiple(query).Entities); // getting the result and add it to a threadsafe list Parallel.ForEach( result, new ParallelOptions {MaxDegreeOfParallelism = 4}, // using maximum parallelism of 4, as crm usually only allows 4 connections per ip solution => { _log.Info($"Deleting solution {solution.GetAttributeValue<string>("uniquename")}"); // writing the solutionname to the log orgService.Delete(solution.LogicalName, solution.Id); // deleting the solution } ); } |