When a running application creates an instance of XmlSerializer, it generates a temporary assembly containing the implementation of the serializer. This happens once for each type for which an XmlSerializer is needed. To improve performance, we can use Microsoft XmlSerializer Generator to pre-generate code for an XmlSerializer for each specified type in a project and compile it into an assembly. This assembly will then be used by the application when creating an XmlSerializer instead of generating a temporary one.
The version number is just above the link of the installer e.g. version 2.0.4-servicing-25831-01. You need specify the version through RuntimeFrameworkVersion in your .csproj like the following.
1. Create a library project that contains your custom data types. E.g. create a library named MyLibrary using the CLI: `dotnet new library --name MyLibrary`
4. Run `dotnet restore` and `dotnet build` to build the library. If everything succeeds, a file named MyLibrary.XmlSerializers.dll will be generated in the output folder. You will see warnings in the build output if the serializer failed to generate.
Now you can use the library with a console app by adding a project reference to the library. Building the app will generate serialization code for the library and the assembly will be copied to the output folder of the app. You need make sure your console app will use the latest 2.0 build by specifying the RuntimeFrameWorkVersion as mentioned in Prequisition.