views:

108

answers:

1

I have a sgen build step in my .NET 3.5 library. In VS2010 this generates .NET 4 MyLib.XmlSerializers.dll, which cannot be loaded from .NET 3.5 apps. Does anyone know how to change build step to get correct version of the assembly? Is it possible to IL merge serializers assembly and library into single dll?

This is my sgen build step:

<Target Name="AfterBuild" DependsOnTargets="AssignTargetPaths;Compile;ResolveKeySource" Inputs="$(MSBuildAllProjects);@(IntermediateAssembly)" Outputs="$(OutputPath)$(_SGenDllName)">
    <!-- Delete the file because I can't figure out how to force the SGen task. -->
    <Delete Files="$(TargetDir)$(TargetName).XmlSerializers.dll" ContinueOnError="true" />
    <SGen BuildAssemblyName="$(TargetFileName)" BuildAssemblyPath="$(OutputPath)" References="@(ReferencePath)" ShouldGenerateSerializer="true" UseProxyTypes="false" KeyContainer="$(KeyContainerName)" KeyFile="$(KeyOriginatorFile)" DelaySign="$(DelaySign)" ToolPath="$(SGenToolPath)">
      <Output TaskParameter="SerializationAssembly" ItemName="SerializationAssembly" />
    </SGen>
  </Target>

Thanks

EDIT: I have found the same question here, but I'll wait for a while to see if someone has a better solution.

A: 

You could use the .NET 3.5 sgen.exe:

ToolPath="C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin"

You will need to make sure that the assembly containing the type you want to sgen is targeting .NET 3.5.

Darin Dimitrov
Is there something like $(SGen35ToolPath) or I have to hardcode this path?
Marko