Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Build error when using "Generate serialization assembly" option in a .NET Standard class library project #418

Closed
mizbrodin opened this issue Jul 10, 2017 · 10 comments
Assignees

Comments

@mizbrodin
Copy link

Hello,

I'm using Visual Studio 2017 Preview (15.3.0 Preview 3.0) and Microsoft .NET Core SDK 2.0.0 Preview 2.

When I try to build a class library project targeting .NET Standard 2.0 and having GenerateSerializationAssemblies option set to On, I get the following build error:

SGEN : error : An attempt was made to load an assembly with an incorrect format: C:\Users\max62689.nuget\packages\netstandard.library\2.0.0-preview2-25401-01\build\netstandard2.0\ref\netstandard.dll.

The same happens if I'm using this option in a class library targeting .NET Framework 4.6.1 but referencing a .NET Standard 2.0 library.

Is this an expected behaviour?

@weshaggard
Copy link
Member

@zhenlan do you know who to route this question to?

@zhenlan
Copy link
Member

zhenlan commented Jul 11, 2017

@mizbrodin I suspect what is triggered by GenerateSerializationAssemblies option is the sgen.exe for full .NET Framework. It won't work for .NET Core/.NET Standard assemblies. We are working in progress a solution for Core. You can find more details from dotnet/corefx#4561.

cc: @shmao @huanwu fyi

@mizbrodin
Copy link
Author

@zhenlan I have this problem even when I try to use this option with any .NET Framework class library project having a reference to a library targeting .NET Standard 2.0. Is this an expected behaviour as well?

@zhenlan
Copy link
Member

zhenlan commented Jul 13, 2017

@mizbrodin I think your scenario (full .NET lib referencing NS lib) is valid. It's the desktop sgen.exe that has no idea of what netstandard.dll is. We will have to take a closer look to understand what exactly went wrong. Thanks for reporting the issue!

@mizbrodin
Copy link
Author

@zhenlan Thank you. Can you confirm if we will be able to use GenerateSerializationAssemblies option in my .NET Standard 2.0 class library projects when the issue dotnet/corefx#4561 is solved? Will your solution for .NET Core work automatically for .NET Standard projects as well?

@zhenlan
Copy link
Member

zhenlan commented Jul 17, 2017

Yes, dotnet/corefx#4561 will work for both .NET Core and .NET Standard projects. We are still working on the end user experience. The reason GenerateSerializationAssemblies option works for full .NET is because desktop SGEN's MsBuild target ships with MsBuild/VS. The new .NET Core/Standard SGEN will likely be a standalone NuGet package and a user needs to install it to a project. I hope the experience can be as simple as possible, but I am not sure if it can be the same.

@zhenlan
Copy link
Member

zhenlan commented Nov 2, 2017

@shmao

@CZEMacLeod
Copy link

Is this going to be released as a separate NuGet package / build task or is it just going to be part of the SDK? I am hitting problems with the current SGen from a 'legacy' project targeting net461 that imports netstandard2 because of dependencies and now the original SGen task fails.
It would be very nice to be able to just import a package and have sgen turn on without having to set GenerateSerializationAssemblies or anything.

@shmao
Copy link

shmao commented Nov 8, 2017

@CZEMacLeod we just released a nuget package, Microsoft.XmlSerializer.Generator, which is for pre-generating XmlSerializer on .Net Core and .Net Standard. Please see the announcement for more details.

We are actively looking to improve the tool and your input is a valuable part of the process.

@wtgodbe
Copy link
Member

wtgodbe commented May 30, 2019

Closing for lack of traction, @mizbrodin please reopen if you're still having problems.

@wtgodbe wtgodbe closed this as completed May 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants