How to convert changes set to Package.xml?

it happens that in the moment of migration there are some inconveniences with the production. To work around this problem, it is better to migrate with a defined package.xml. We can start from the change set. I’ll explain how.

An example would be layout assignments. I had problems migrating profiles with visual studio. Profiles were loaded into production, as well as page layouts and record types, but there was no correct assignment in the profiles

To solve the problem I created a change set with profiles, record type and page layout and then I converted the change set into a package.xml and filtered with the desired information.

				
					sfdx force:source:retrieve -n "My Change Set Name"
				
			

or

				
					sfdx force:mdapi:retrieve -r "outputDir" -p "My Change Set Name"
				
			

After retrivating the change set, you will be shown the folder where to find the files. Open the profile files and you will notice a structure like this

				
					<?xml version="1.0" encoding="UTF-8"?>
<Profile xmlns="http://soap.sforce.com/2006/04/metadata">
    <custom>false</custom>
    <layoutAssignments>
        <layout>Object Layout</layout>
        <recordType>Object.RECORDTYPE</recordType>
    </layoutAssignments>