Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to compile it in vs2017 with target frameowrk to .net 3.5 #262

Closed
Qtan75 opened this issue Jun 10, 2017 · 18 comments
Closed

How to compile it in vs2017 with target frameowrk to .net 3.5 #262

Qtan75 opened this issue Jun 10, 2017 · 18 comments
Milestone

Comments

@Qtan75
Copy link

Qtan75 commented Jun 10, 2017

Hi,
I am trying to rebuild this library to target framework .net 3.5. However, when I got to the right clicked project name Protobuf-net, properties, application tab, the target framework field is grayed out and can not be changed.

Is there a way to set the target framework to .net 3.5?

Thank you!

@mgravell
Copy link
Member

mgravell commented Jun 10, 2017 via email

@Qtan75
Copy link
Author

Qtan75 commented Jun 10, 2017

Hi,
Thanks for the response!

@Qtan75
Copy link
Author

Qtan75 commented Jun 10, 2017

Hi,
Is it in the csproj file, just need to change:
net40;netstandard1.3
to
net3.5;netstandard1.3

I can give it a try now.

Thank you!

@mgravell
Copy link
Member

mgravell commented Jun 10, 2017 via email

@Qtan75
Copy link
Author

Qtan75 commented Jun 10, 2017

It works! Thanks!

@Qtan75
Copy link
Author

Qtan75 commented Jun 12, 2017

So after I created the dll from the vs2017 build, with target framework of .Net3.5. Ireferenced it in a Windows Mobile 6.5 application. But unluckily, that WM6.5 application had errors after I have reference the new dll. The first error is:
The type 'System.Xml.Serialization.IXmlSerializable' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Another question I have is: Is it possible to convert this package (protobuf-net) to a vs2008 solution and build it with target frame .Net3.5 in there?

Thank you!

@mgravell
Copy link
Member

mgravell commented Jun 12, 2017 via email

@Qtan75
Copy link
Author

Qtan75 commented Jun 12, 2017

The protobuf-net dll was used for an application developed in vs2008. So has the error happened in. Yes, System.xml is in reference, but the version is 3.5.0.0 for this application. However in the protobuf-net solution, it reference to a version of 2.0.0.0 for the System.Xml it is using.

Since vs2008 is used for my application, so that's why I was trying to build the protobuf-net.dll in vs2008. thought this could but actually may not.

@Qtan75
Copy link
Author

Qtan75 commented Jun 12, 2017

When I tried to remove the System.Xml version 2.0.0.0 referenced in the protobuf-net solution, it gave an error:
image

@mgravell
Copy link
Member

mgravell commented Jun 12, 2017 via email

@mgravell
Copy link
Member

mgravell commented Jun 13, 2017 via email

@Qtan75
Copy link
Author

Qtan75 commented Jun 13, 2017

So I have tried adding a line:

<PackageReference Include="System.Xml" Version="3.5.0.0" />

into the csproj xml, however, then vs2017 shows build errors:
Unable to resolve 'System.Xml (>= 3.5.0)' for '.NETFramework,Version=v3.5'.
Unable to resolve 'System.Xml (>= 3.5.0)' for '.NETFramework,Version=v4.5.2'.
Unexpected dependency 'System.Xml' with no version number.

Any insights on those?

@mgravell
Copy link
Member

mgravell commented Jun 13, 2017

Yeah, this isn't a package reference on regular .NET; it is a framework reference. Try:

<Reference Include=System.Xml" />

It is, however, a package reference in .NET core. Build tools are fun :/ I have fun Condition markers to do things like this, for example in protobuf-net itself:

  <ItemGroup Condition="'$(ImportLibs)|$(FeatureServiceModel)' == 'net|true'">
    <Reference Include="System.ServiceModel" />
    <Reference Include="System.Configuration" />
    <Reference Include="System.Runtime.Serialization" />
  </ItemGroup>
  <ItemGroup Condition="'$(ImportLibs)' == 'core'">
    <!-- could make this more granular to respect the options, but no need yet -->
    <PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
    <PackageReference Include="System.Reflection.Emit.ILGeneration" Version="4.3.0" />
    <PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.3.0" />
    <PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
    <PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0" />
    <PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
  </ItemGroup>

However, I'm slightly confused because IIRC System.Xml is actually included by default. Sheesh.

The fact is the build tools are a bit of a mess right now (for .NET / .NET core generally, not this library specifically). It is causing me pain on a number of projects. Fixes are in the pipelines, but are outside of my control.

@Qtan75
Copy link
Author

Qtan75 commented Jun 13, 2017

Ok, I have changed it to:

However, under the Dependencies, Assemblies, The System.Xml is still 2.0.0.0. I will need 3.5. It's strange because the System.Xml.Linq is 3.5.

But now the build error is gone.

@mgravell
Copy link
Member

mgravell commented Jun 13, 2017

If you're targetting .NET 3.5, then it is System.Xml 2.0; .NET 3.5 are incremental additions to .NET 2.0 via additional assemblies; the base assembles do not change (except for bugfixes etc, but they didn't increase the major version).

Because System.Xml.Linq is one of those additions in .NET 3.5, it gets the 3.5 versioning; however System.Xml: does not - it stays 2.0

In .NET 4.0, they all become 4.0.

@Qtan75
Copy link
Author

Qtan75 commented Jun 13, 2017

got it. However, in the other project that uses this protobuf-net.dll, it has a System.Xml reference version of 3.5. So we were wondering if that could help.

Thanks for the help!

@mgravell
Copy link
Member

AFAIK (and I'm happy to be corrected): System.Xml 3.5 does not exist.. at least, not in regular .NET. If it exists in some Mono / Unity / whatever branch, then fine.

@mgravell
Copy link
Member

Closing issue; 2.3.0 will include 2.0 and 3.5 builds via the "VS" configuration (that only works in VS, hence the name)

@mgravell mgravell added this to the 2.3.0 milestone Jun 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants