views:

402

answers:

2

I have a build process which takes my VS 2008 .NET 2.0 ASP.NET project and builds it using MSBuild. The project contains ASPX files, plus a web service, and also connects to another web service ;)

All seems to work well except MSBuild puts the *.XmlSerializers.dll assembly file into the folder _PublishedWebsites\MySite rather than in _PublishedWebsites\MySite\bin like it does with the other dll.

Does it matter that the *.XmlSerializers.dll assembly file is not in the bin folder?

Or should I use my build process to copy the *.XmlSerializers.dll assembly into the bin folder after MSBuild has finished?

+2  A: 

You don't need this assembly unless you will be serializing and deserializing types from your assembly. This assembly is generated by the compiler to save your application from having to generate it once it is up and running.

If you intend on doing serialization, keep the assembly as it will help with performance. If you don't intend on doing any serialization then feel free to ignore it or remove it altogether.

For more information about this practice please see XML Serializer Generator Tool:

The XML Serializer Generator creates an XML serialization assembly for types in a specified assembly in order to improve the startup performance of a XmlSerializer when it serializes or deserializes objects of the specified types.

Andrew Hare
Thanks. I do use serialization to turn some of my classes in to XML and back. What I don't understand is should I move the *.XmlSerializers.dll assembly into the bin folder or leave it in the base folder of the web application?
Matthew Lock
Move it into the `\bin` directory so that the CLR can find it.
Andrew Hare
A: 

Yes, it does matter that the XmlSerializers assembly is not in the bin directory. Using the Fusion Log Viewer I confirmed my suspicion that the DLL was not being loaded when it was left in the web application root.

To correct this, you can add an AfterBuild target that moves the file to the correct location. I use the following snippet, but newer versions of MsBuild have a Move task:

  <Target Name="AfterBuild">
    <!-- Don't do this when the final destination is the same as build destination (local builds) -->
    <Exec Command="move /Y &quot;$(WebProjectOutputDir)\$(AssemblyName).XmlSerializers.dll&quot; &quot;$(WebProjectOutputDir)\bin&quot;" Condition="'$(OutDir)' != '$(OutputPath)'"/>
  </Target>

Note: If you are building and running the web app from the same directory (as is usually the case when running locally on your dev machine) and have the project setting "Generate serialization assembly" set to On, the file is generated in the bin directory. This is why I configured the task not to be executed in that case.

I could have simply made sure the file existed, but I wanted to make sure the build failed if for some reason the file was not in the expected place during integration builds.

Mario