I try to publish a .net Core (WinForms) project, which I upgraded from core3.0 to net5.0, as Single Exe.
I get the following error:
NETSDK1142: Including symbols in a single file bundle is not supported when publishing for .NET5 or higher.
researching NETSDK1142 I do not get any results in google regarding a fix.
With Core3.0 the following command worked:
dotnet publish nameofproject.csproj \
-o bin/Release/core \
-c Release \
-p:Platform=x64 \
-r win-x64 \
--self-contained true
I also tried the following flags for net5.0. Still getting the same error even with DebugSymbols=false
dotnet publish nameofproject.csproj \
-o bin/Release/core \
-c Release \
-p:Platform=x64 \
-p:NoWarn=CS0618 \
-p:NoWarn=NU1605 \
--self-contained true \
-p:PublishSingleFile=true \
-p:IncludeAllContentForSelfExtract=true \
-p:PublishReadyToRun=true \
-p:PublishTrimmed=false \
-p:IncludeNativeLibrariesForSelfExtract=true \
/p:DebugType=None /p:DebugSymbols=false
just add -p:IncludeSymbolsInSingleFile=false
or /p:IncludeSymbolsInSingleFile=false
to the publish command
After trying to fix the issue since 2 days the solution was found in the dotnet/sdk Source Code.
in sdk/src/Tasks/Common/Resources/Strings.resx
I found the error string
<data name="CannotIncludeSymbolsInSingleFile" xml:space="preserve">
<value>NETSDK1142: Including symbols in a single file bundle is not supported when publishing for .NET5 or higher.</value>
<comment>{StrBegin="NETSDK1142: "}</comment>
</data>
then I tracked down the CannotIncludeSymbolsInSingleFile
string resource in the sourcecode and found the following result in sdk/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets
<NETSdkError Condition="'$(PublishSingleFile)' == 'true' And
'$(IncludeSymbolsInSingleFile)' == 'true' And
'$(_TargetFrameworkVersionWithoutV)' >= '5.0' And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'"
ResourceName="CannotIncludeSymbolsInSingleFile" />
There I found the Flag I had to set on build IncludeSymbolsInSingleFile
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.