How to force Sgen to create .net 3.5 serializers assembly

孤街醉人 提交于 2019-12-09 20:53:48

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3350780/how-to-force-sgen-to-create-net-3-5-serializers-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!