开发者

Why does MSBuild put *.XmlSerializers.dll assembly in the root folder of published web application?

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 ass开发者_C百科embly into the bin folder after MSBuild has finished?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜