-
Notifications
You must be signed in to change notification settings - Fork 1.1k
.NET 4.6.1/.NET Standard 2.0 build with SGen fails #1630
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
Comments
One thing that allowed me to go on, was to patch quite violently the This removed the ref DLLs from the list of DLLs passed to the SGen task.
|
My company just ran into this. I'm not quite brave enough to use the workaround yet. We don't run into this so long as we don't add a package reference to SourceLink.Embed.AllSourceFiles. |
I'll have to have a look again at this. The workaround is simple enough to implement: copy paste the target in the .csproj after the Import of the targets (). |
I'm just afraid to entirely replace the target. I just found a workaround for my particular case which I'll post here. |
do your patch work for .NET Framework 4.7.1 ? I get this error But i m not referincing this DLL in my project ! any help please ? |
@joperezr can you take a look and comment? |
@mouadhtrabelsi that reference is automatically added in order to ensure compatibility between your .Net Framework component and your .Net standard one. Do you mind sharing a repro and also the version of VS that you are using so that I can provide a workaround? |
@joperezr There are some simple repro steps at dotnet/msbuild#2707 |
I have the same problem as @mouadhtrabelsi, in my WebForms App targeting 4.7.1 when building Relase. |
I I got this error only in project having web service refrences
|
@mouadhtrabelsi It worked! Thanks a lot! |
I am getting this on a regular ASP.NET project when I upgraded to .NET 4.7.1 and it has references to .NET Standard 2.0 libs. Is there any official guidance on how this is going to get addressed? I'm on the latest VS - 15.5.6 |
I believe we do know now what is happening here. In order for SGen to work correctly on 4.7.1, it will require one of two possible solutions:
<Target Name="RemoveDesignTimeFacadesBeforeSGen" BeforeTargets="GenerateSerializationAssemblies">
<ItemGroup>
<ReferencePath Remove="@(_DesignTimeFacadeAssemblies_Names->'%(OriginalIdentity)')" />
</ItemGroup>
<Message Importance="normal" Text="Removing DesignTimeFacades from ReferencePath before running SGen." />
</Target>
<Target Name="ReAddDesignTimeFacadesBeforeSGen" AfterTargets="GenerateSerializationAssemblies">
<ItemGroup>
<ReferencePath Include="@(_DesignTimeFacadeAssemblies_Names->'%(OriginalIdentity)')" />
</ItemGroup>
<Message Importance="normal" Text="Adding back DesignTimeFacades from ReferencePath now that SGen has run." />
</Target>
|
@joperezr 's solution (thanks Jose) worked for my Debug build, but not for Release, unfortunately. However it builds fine in Release mode on Visual Studio Online's hosted agent, so I assume it's something to do with what's installed on your local machine. DLL hell never really went away! |
I am still using msbuild to do my builds. The issue cropped up for us after some updates to vs2017. After reading this thread, I added '/p:GenerateSerializationAssemblies=Off' to the build script and that resolved the issue with the project that was failing. Note: this was happening on the build server, and not on the developers workstations. |
@rfcfore In my case, I am working on a legacy project with lots of technical debt. I'm afraid setting the |
I'm experiencing a similar issue. Please also see my post: NuGet package (.NET Standard 2.x) breaking ASP.NET MVC5 application (.NET full framework) |
I found a different workaround. Call sgen manually in a post build event like this: Sgen.exe /force "$(TargetPath)" /c:"-reference:$(TargetDir)netstandard.dll" You also need to call vcvarsall.bat or similar first so that sgen can be found |
I'm having a similar issue to @mouadhtrabelsi - GenerateSerializationAssemblies is set to 'Auto' and therefore I only get this problem in Release builds. We're running net471 - not sure if thats I've have tried @emmanuelguerin fix, but that didn't help (either that or I'm doing it worng - I literally just put his build target into my csproj) I have tried @joperezr fix but again, no effect (as before, unless I'm doing it wrong). I'm looking at setting GenerateSerializationAssemblies to false, but not sure what the wider effects will be. Anybody got an update? |
@mattwhetton if your machine runs on 4.7.1 (and you have installed latest windows updates) or if you are running on 4.7.2 then you shouldn't hit this issue at all. Not on Debug builds or Release builds. Do you mind trying to update your machine to make sure you have the latest Windows Updates and trying again? |
I'm running on 4.7.1 and my updates look fairely up to date. We're seeing this issue on our build serverr too. I'm actually working within a company network where updates are controlled by group policy, and rolled out in a very managed way. Do you have any more details on specifically which update this fix was in? Looking at my update history, the last successful update was on 29/06/2018 which was KB2693643 and there is nothing showing as outstanding. |
@mattwhetton I see, I can't seem to be able to repro your issue but I'm on 4.7.2. Can you send me your OS Version and the File version of the clr.dll file that gets loaded into the process? That way I can try to set up a machine with your environment and try to get a repro there. Hopefully after that I will be able to provide either a workaround, or an Update package that you are missing. |
System: Win10(1809 17744 Insyder) Or you mean set
projects <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<GenerateSerializationAssemblies>on</GenerateSerializationAssemblies><!--1. Add this-->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Buffers" Version="4.5.0" /><!--2. Add this-->
</ItemGroup>
</Project> |
There is no SGen specifically for net4.7.2, what I meant is that if you were running on 4.7.2 (meaning that you have .NET Framework 4.7.2 installed on your machine) then you wouldn't hit this issue, even when running the tool which targets 4.6.1. Is it possible for you to upgrade to a newer framework in your machine and try again? |
@joperezr It's already 4.7.2 for #1630 (comment) |
@joperezr Yes, I have one 4.7.2 here, and one But according to https://blogs.msdn.microsoft.com/dotnet/2018/07/10/net-framework-4-7-2-is-available-on-windows-update-wsus-and-mu-catalog/ , seems there is still an new version of net472 with |
I am also having this issue with an on-prem windows 10 VSTS build agent
Tried all sorts of fixes but had no luck, been trying to fix the issue for 3 days, please help I am running on .NET 4.7.2, have installed the latest win 10 SDK |
Heres a dump of the verbose msbuild log, tried all workarounds
|
Frustrating. Are you sure all your projects are targeting 4.7.2 as well as just having it installed? I know the Remove/ReAddDesignTimeFacadesBeforeSGen fix of joperezr's (Feb 5 above) is specifically a workaround for 4.7.1, but have you tried that too? Desperate times, etc. |
Frustrating aint the word, starting to contemplate my career choice lol, tried all work arounds :(, no luck..
|
@theCorb1nator did you try to deactivate
from the log you sent, i think its activated
|
@mouadhtrabelsi i can confirm turning that param off the application does compile correctly. however surely this will have an affect on application performance at runtime? and possible runtime errors? im happy for this to be a temporary solution, but is there a planned fix? Thanks |
@theCorb1nator for sure there will be an impact on performance at runtime , but i did not get any runtime errors, |
Okay looks like this is the only fix for now then. i dont think we do much with XmlSerializer now anyways, its predominately JSON using newtonsoft. so hopefully not too much overhead Thanks for the help |
looks like the issue is still open here |
Dear, However, the client can migrate a build of the components to the 64-bit version, although it is somewhat exposed to some scripts. An attempt was made to load an assembly with an incorrect format: c: \ windows \ microsoft.net \ framework \ v2.0.50727 \ System.Data.dll |
I love this, it happens to me all of the time, and when you get a solution you appreciate hanging in there :) |
I have too been bitten by this (netstandard2.1 assembly, but otherwise equivalent). It has now been over two years since this issue was opened, and not even a hint of what Microsoft is doing about this (indication is rather that Microsoft isn't doing anything about it). To put it mildly, that's absurd. Is this the kind of quality and apathy one should now expect from Microsoft. We're talking about over two years! Have you just given up, moved on to greener pastures, abadoning your customers? Wouldn't be the first time, but if so you could at least man up and tell us so! off-topic, but since it seems you (Microsoft representatives) don't realize this, perhaps it can be an eye-opener: Do you (Microsoft representatives) even realize how bad this reflects on Microsoft as a whole? Apathy like this is what makes friends tell friends to "Stay the hell away from .NET (and while at it get rid of anything Microsoft)". Is that the message you want to send your customers? 'cause that's the message you do send them by apathy like this. Is that the message you want Microsoft to be known for? Is that the message you can proudly proclaim for your boss, the boss' boss, all the way up to CEO and shareholders, with a smile and completely unwarranted pride with loud a clear voice state "We don't give a fuck about neither our products nor our customers!". (yes, I'm pissed off, and so would you be after you've went through the same shit due to this buggy crap - it's a clusterf... of such proportions we've seriously started considering porting everything to Java, just to get rid of you) |
For me, a similar work around like Joses helped. I'm just temporarily removing all reference assemblies. <Target Name="RemoveReferenceAssembliesBeforeSGen" BeforeTargets="GenerateSerializationAssemblies">
<ItemGroup>
<_Ref_NoSgenPaths Include="%(ReferencePath.Identity)" Condition="@(ReferencePath->Contains('\ref\'))"/>
<ReferencePath Remove="%(ReferencePath.Identity)" Condition="@(ReferencePath->Contains('\ref\'))" />
</ItemGroup>
</Target>
<Target Name="ReAddReferenceAssembliesAfterSGen" AfterTargets="GenerateSerializationAssemblies">
<ItemGroup>
<ReferencePath Include="@(_Ref_NoSgenPaths)"/>
</ItemGroup>
</Target> Thanks for the MSBuild Structured Log Viewer making it possible to efficiently analyze issues like this. |
Just had this issue for the first time doing a release build of a solution that has built correctly for years: This is in a project that has WCF web service references, The project is targeting anyCPU and .net Framework 4.7.2. The latest installed .Net Framework on my PC is 4.8, as well as 4.7.2. Recent changes since I last did a release build: Upgraded to VS 16.8.1, migrated from packages.config to PackageReferences using the tool in Visual Studio |
This document has more information on how to do this in .NET Core https://docs.microsoft.com/en-us/dotnet/core/additional-tools/xml-serializer-generator |
Worked PERFECTLY |
…606.1 (#1630) [main] Update dependencies from dotnet/arcade
The context is a .NET Standard 2.0 targeted library Lib. It is referenced by a .NET Framework 4.6.1 targeted library LibNetFramework.
(see GitHub repository: https://github.com/emmanuelguerin/issue-sgen)
In LibNetFramework, serialization assemblies generation is forced by the use of the
GenerateSerializationAssemblies
property set toOn
. Typically, this would happen when adding a WebReference to the project.The compilation fails with the message
The issue might have been corrected by the use of the patch in #1582, that is put ine the LibNetFrameworkPatched project in the GitHub repo.
But this breaks the build, as the netstandard.dll reference is no longer added to the compilation:
You can find an appveyor build failing on the VS2017, and VS2017 preview:
https://ci.appveyor.com/project/emmanuelguerin/issue-sgen/build/1.0.6
The text was updated successfully, but these errors were encountered: