Search code examples
.netserializationversionsgen

How to make sgen.exe keep the version of the assembly?


I want to create a serialization assembly for my assembly. sgen does it fine, but I can't figure out how to get it to assign the serialization assembly the same version as the source assembly.

Any ideas?


Solution

  • sgen seem to take source assembly version by default, it is quite reasonable.

    Here is how I run it, there is nothing special:

    "...PathToSDK...\Microsoft Visual Studio SDK\sgen.exe" /force /assembly:"$(TargetPath)" /compiler:"\"/keyfile:$(ProjectDir)..\key.snk"\" /compiler:/delaysign-

    /force -- to overwrite existing serializer assemblies

    /assembly -- path to the assembly, I run it in the post-build event in the VS project settings, so I use the $(TargetPath) variable

    /compiler: ... -- csc options, I use them to sign serializer assemblies with the key