Closed petrsvihlik closed 2 years ago
Hi,
NET6 will be added as a target, but first we need resolve following issues:
According to .NET 6 target.
I have tried to implement new targets (#126).
I was forced to set target to net5.0;net6.0
for console project. Because pack step (dotnet pack --no-build --verbosity normal --configuration Release --output ./artifacts /p:PackageVersion="66.6.6"
) raised this warning when targets were set to netstandard2.0;net6.0
:
C:\Program Files\dotnet\sdk\6.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.PackTool.targets(89,5): error NETSDK1054: only supports .NET Core. [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
"C:\projects\kontent-generators-net\kontent-generators-net.sln" (pack target) (1) ->
"C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj" (pack target) (4) ->
"C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj" (_GetTfmSpecificContentForPackage target) (4:3) ->
(_PackToolValidation target) ->
C:\Program Files\dotnet\sdk\6.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.PackTool.targets(89,5): error NETSDK1054: only supports .NET Core. [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
Second warning is about trimming
After adjusting self-contained.ps1
file. There is also a warning for dotnet publish ... -p:PublishTrimmed=true
For .NET 6, there is also this warning about linked libraries not being ready for trimming.
ILLink : Trim analysis warning IL2026: System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.GetSchema(): Using member 'System.Data.DataSet.WriteXmlSchema(DataSet,XmlWriter)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. DataSet.GetSchema uses TypeDescriptor and XmlSerialization underneath which are not trimming safe. Members from serialized types
may be trimmed if not referenced directly. [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
ILLink : Trim analysis warning IL2026: System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.ReadXml(XmlReader): Using member 'System.Data.DataSet.ReadXmlSerializableInternal(XmlReader)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. DataSet.ReadXml uses XmlSerialization underneath which is not trimming safe. Members from serialized types may be trimmed if not referenced directly. [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
ILLink : Trim analysis warning IL2026: System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.WriteXml(XmlWriter): Using member 'System.Data.DataSet.WriteXmlInternal(XmlWriter)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. DataSet.WriteXml uses XmlSerialization underneath which is not trimming safe. Members from serialized types may be trimmed if not referenced directly. [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
ILLink : Trim analysis warning IL2026: System.Data.DataTable.System.Xml.Serialization.IXmlSerializable.GetSchema(): Using member 'System.Data.DataTable.GetXmlSchema()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. DataTable.GetSchema uses TypeDescriptor and XmlSerialization underneath which are not trimming safe. Members from serialized types may be trimmed if not referenced directly. [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
ILLink : Trim analysis warning IL2026: System.Data.DataTable.System.Xml.Serialization.IXmlSerializable.ReadXml(XmlReader): Using member 'System.Data.DataTable.ReadXmlSerializableInternal(XmlReader)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. DataTable.ReadXml uses XmlSerialization underneath which is not trimming safe. Members from serialized types may
be trimmed if not referenced directly. [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
ILLink : Trim analysis warning IL2026: System.Data.DataTable.System.Xml.Serialization.IXmlSerializable.WriteXml(XmlWriter): Using member 'System.Data.DataTable.WriteXmlInternal(XmlWriter)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. DataTable.WriteXml uses XmlSerialization underneath which is not trimming safe. Members from serialized types may be trimmed if not referenced directly. [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
C:\Users\OndrejCh\.nuget\packages\anglesharp\0.14.0\lib\netstandard2.0\AngleSharp.dll : warning IL2104: Assembly 'AngleSharp' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
C:\Users\OndrejCh\.nuget\packages\humanizer.core\2.2.0\lib\netstandard1.0\Humanizer.dll : warning IL2104: Assembly 'Humanizer' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
C:\Users\OndrejCh\.nuget\packages\kentico.kontent.delivery\14.2.1\lib\netstandard2.0\Kentico.Kontent.Delivery.dll : warning IL2104: Assembly 'Kentico.Kontent.Delivery' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
C:\Users\OndrejCh\.nuget\packages\kentico.kontent.management\2.1.0\lib\netstandard2.0\Kentico.Kontent.Management.dll : warning IL2104: Assembly 'Kentico.Kontent.Management' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
C:\Users\OndrejCh\.nuget\packages\microsoft.codeanalysis.common\3.8.0\lib\netcoreapp3.1\Microsoft.CodeAnalysis.dll : warning IL2104: Assembly 'Microsoft.CodeAnalysis' produced trim warnings. For more informapaces' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
C:\Users\OndrejCh\.nuget\packages\microsoft.codeanalysis.workspaces.common\3.8.0\lib\netcoreapp3.1\Microsoft.CodeAnalysis.Workspaces.dll : warning IL2104: Assembly 'Microsoft.CodeAnalysis.Workspaces' produceC:\Users\OndrejCh\.nuget\packages\microsoft.extensions.configuration.binder\2.1.1\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll : warning IL2104: Assembly 'Microsoft.Extensions.Configuration.Binder' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
C:\Users\OndrejCh\.nuget\packages\microsoft.extensions.dependencyinjection\5.0.1\lib\net5.0\Microsoft.Extensions.DependencyInjection.dll : warning IL2104: Assembly 'Microsoft.Extensions.DependencyInjection'
produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
ormation see https://aka.ms/dotnet-illink/libraries [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
C:\Users\OndrejCh\.nuget\packages\newtonsoft.json\12.0.3\lib\netstandard2.0\Newtonsoft.Json.dll : warning IL2104: Assembly 'Newtonsoft.Json' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
C:\Users\OndrejCh\.nuget\packages\scrutor\3.2.2\lib\netstandard2.0\Scrutor.dll : warning IL2104: Assembly 'Scrutor' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
C:\Users\OndrejCh\.nuget\packages\system.composition.convention\1.0.31\lib\netstandard1.0\System.Composition.Convention.dll : warning IL2104: Assembly 'System.Composition.Convention' produced trim warnings.
For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
C:\Users\OndrejCh\.nuget\packages\system.composition.hosting\1.0.31\lib\netstandard1.0\System.Composition.Hosting.dll : warning IL2104: Assembly 'System.Composition.Hosting' produced trim warnings. For more
information see https://aka.ms/dotnet-illink/libraries [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
C:\Users\OndrejCh\.nuget\packages\system.composition.typedparts\1.0.31\lib\netstandard1.0\System.Composition.TypedParts.dll : warning IL2104: Assembly 'System.Composition.TypedParts' produced trim warnings.
For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\kontent-generators-net\src\Kentico.Kontent.ModelGenerator\Kentico.Kontent.ModelGenerator.csproj]
According to the second part of the previous comment (trimming).
I can remove -p:PublishTrimmed=true
from self-contained.ps1
file - do you remember the reason for placing it here @petrsvihlik ?
@Simply007 it was added to make the package smaller. try publishing it without the param and compare the size to the trimmed version
ref - https://docs.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-self-contained
I was forced to set target to net5.0;net6.0
that's what you were supposed to do...I don't understand that comment
..I don't understand that comment
I wanted to set the target to netstandard2.0;net6.0
. - original comment was updated.
@Simply007 it was added to make the package smaller. try publishing it without the param and compare the size to the trimmed version
ref - https://docs.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-self-contained
Yeap - but the trimming is supported for .NET6+ according to:
So this argument was useless in my opinion (after very brief skiming) for net5.0
target. And for 6.0 it raises trim analysis warnings for a couple of libraries, so we should not use it.
I wanted to set the target to netstandard2.0;net6.0. - original comment was updated.
yeah, netstandard is not a valid target for exe...it's only supposed to be used for libs
Yeap - but the trimming is supported for .NET6+ according to:
trimming in netcore is supported perhaps since 3.1... how big is the package without trimming?
With trimming
net5.0 osx - 83MB linux - 92MB windows - 83MB
net6.0 osx - 94MB linux - 94MB windows - 97MB
Without trimming
net5.0 osx - 52MB linux - 62MB windows - 52MB
net6.0 (with warnings) osx - 52MB linux - 52MB windows - 51MB
I can run trimming for .NET5 and skip it for .NET6, but it feels strange when official docs says: "Trimming is only supported in .NET 6+." "Ensure you're using the .NET 6 SDK or later for these steps. They will not work correctly in previous versions."
You confused the with/without trimming categories right? The smaller ones are the trimmed ones, right?
Anyways, not sure why the docs say that. Perhaps it was in some experimental mode before...dunno.
Is it only warnings? If the app works, you can keep it enabled for both and perhaps address the warnings in a separate issue. I think that it'll be a matter of properly configuring the linker and providing it with some hints. If I'm not mistaken, you can add a LinkerConfig.xml to the project and add more granular configuration.
https://github.com/petrsvihlik/StartBootstrap.Freelancer.Blazor/runs/4340415677?check_suite_focus=true
Worked around by:
https://github.com/petrsvihlik/StartBootstrap.Freelancer.Blazor/blob/711d4a2abca1cd0c659795ee906d7c902b2e03a4/.github/workflows/publish.yml#L18-L23
Please add the net6 target.