dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.7k stars 1.06k forks source link

error MSB6006: "dotnet.exe" exited with code -532462766. (With PublishTrimmed=true) #3668

Open gmeks opened 5 years ago

gmeks commented 5 years ago

Host (useful for support): Version: 3.0.0 Commit: 7d57652f33

If i enabled PublishTrimmed=true when trying to publish a .net Core 3.0 application ( Newly updated from .net Core 2.2) i get the following error: C:\SourceCode\PlaniaHomeMVC\BuildServerAgent>dotnet publish -c Release -r win10-x64 /p:PublishSingleFile=true /p:PublishTrimmed=true Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 26,23 ms for C:\SourceCode\PlaniaHomeMVC\PlaniaHomeShared\PlaniaHomeShared.csproj.
  Restore completed in 40,52 ms for C:\SourceCode\PlaniaHomeMVC\HomeAgentShared\HomeAgentShared.csproj.
  Restore completed in 40,68 ms for C:\SourceCode\PlaniaHomeMVC\BuildServerAgent\BuildServerAgent.csproj.
  PlaniaHomeShared -> C:\SourceCode\PlaniaHomeMVC\PlaniaHomeShared\bin\Release\netcoreapp3.0\PlaniaHomeShared.dll
  HomeAgentShared -> C:\SourceCode\PlaniaHomeMVC\HomeAgentShared\bin\Release\netcoreapp3.0\HomeAgentShared.dll
  BuildServerAgent -> C:\SourceCode\PlaniaHomeMVC\BuildServerAgent\bin\Release\netcoreapp3.0\win10-x64\BuildServerAgent.dll
C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ILLink.targets(87,5): error MSB6006: "dotnet.exe" exited with code -532462766. [C:\SourceCode\PlaniaHomeMVC\BuildServerAgent\BuildServerAgent.csproj]

And im unsure what i have done wrong, i assume i missed something in the upgrade to .NET Core 3.0. If i remove PublishTrimmed it works

livarcocc commented 5 years ago

@@jeffschwMSFT is this something you can direct?

jeffschwMSFT commented 5 years ago

@gmeks can you share out the binlogs? dotnet build /bl

cc @sbomer

gmeks commented 5 years ago

If i change dotcore publish to build, it works.

But your suggestion remined me that offcourse there has to be a better log, so this is with -v d

The error lines: Fatal error in IL Linker Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'declaringType') at Mono.Cecil.Mixin.CheckType(Object type, Argument argument) at Mono.Linker.Steps.TypeMapStep.CreateGenericInstanceCandidate(GenericContext context, TypeDefinition candidateType, MethodDefinition interfaceMethod) at Mono.Linker.Steps.TypeMapStep.GetBaseInflatedInterfaceMethodInTypeHierarchy(GenericContext context, TypeDefinition type, MethodDefinition interfaceMethod) at Mono.Linker.Steps.TypeMapStep.MapInterfaceMethodsInTypeHierarchy(TypeDefinition type) at Mono.Linker.Steps.TypeMapStep.MapType(TypeDefinition type) at Mono.Linker.Steps.TypeMapStep.ProcessAssembly(AssemblyDefinition assembly) at Mono.Linker.Steps.BaseStep.Process(LinkContext context) at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step) at Mono.Linker.Pipeline.Process(LinkContext context) at Mono.Linker.Driver.Run(ILogger customLogger) at Mono.Linker.Driver.Execute(String[] args, ILogger customLogger) at Mono.Linker.Driver.Main(String[] args) 1:7>C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ILLink.targets(87,5): error MSB6006: "dotnet.exe" exited with code -532462766. [C:\SourceCode\PlaniaHomeMVC\BuildServerAgent\BuildServerAgent.csproj] Done executing task "ILLink" -- FAILED. 1:7>Done building target "_RunILLink" in project "BuildServerAgent.csproj" -- FAILED. 1:7>Done Building Project "C:\SourceCode\PlaniaHomeMVC\BuildServerAgent\BuildServerAgent.csproj" (Publish target(s)) -- FAILED.

Full logfile: file.plania.no/File/DLRIA

If i have to guess whats wrong: 1) I did something wrong in upgrading to .net core 3 2) Telerik Dll file the wrong dotnet? ( Not sure if the linked will be able to handle any errors)

jeffschwMSFT commented 5 years ago

The linker communicates via exceptions, which is not a great msbuild experience. We are looking into enabling this. We will take a look at this issue.

cc @tlakollo

sbomer commented 5 years ago

@gmeks thanks for reporting. Could you please provide the full output of dotnet --info? This looks similar to the stack trace from another issue that was fixed earlier this year: https://github.com/mono/linker/pull/567#issue-278478399. We should ensure we're not hitting that issue. Also, I'm not able to access the log file at that URL, could you ensure the link is right? Are you able to provide a repro project that hits this issue? Thanks!

gmeks commented 5 years ago

Sorry forgot that my firewall has very aggresive geo filters, but turns out the ubuntu pastebin is the most generous in terms of size. https://paste.ubuntu.com/p/QnzJBWjtWj/

The project is a part internal/external deployment system so i cannot make it opensource over night. There is also a issue with the telerik dll files, i dont think im allowed to share them in public.

But if its needed we can setup either a screenshare(Time zones might be a issue) or a private repo.

dotnet --info

C:\SourceCode\PlaniaHomeMVC\BuildServerAgent>dotnet --info .NET Core SDK (reflecting any global.json): Version: 3.0.100 Commit: 04339c3a26

Runtime Environment: OS Name: Windows OS Version: 10.0.17763 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support): Version: 3.0.0 Commit: 7d57652f33

.NET Core SDKs installed: 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.503 [C:\Program Files\dotnet\sdk] 2.1.504 [C:\Program Files\dotnet\sdk] 2.1.505 [C:\Program Files\dotnet\sdk] 2.1.602 [C:\Program Files\dotnet\sdk] 2.1.604 [C:\Program Files\dotnet\sdk] 2.1.700 [C:\Program Files\dotnet\sdk] 2.1.701 [C:\Program Files\dotnet\sdk] 2.1.801 [C:\Program Files\dotnet\sdk] 2.1.802 [C:\Program Files\dotnet\sdk] 2.2.103 [C:\Program Files\dotnet\sdk] 2.2.104 [C:\Program Files\dotnet\sdk] 2.2.106 [C:\Program Files\dotnet\sdk] 2.2.202 [C:\Program Files\dotnet\sdk] 2.2.204 [C:\Program Files\dotnet\sdk] 2.2.300 [C:\Program Files\dotnet\sdk] 2.2.301 [C:\Program Files\dotnet\sdk] 2.2.401 [C:\Program Files\dotnet\sdk] 2.2.402 [C:\Program Files\dotnet\sdk] 3.0.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 1.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download

gmeks commented 5 years ago

I have to add a correction, while its true the build completes without PublishTrimmed=true, it will not run.

Failure processing application bundle. Failed to determine location for extracting embedded files A fatal error was encountered. Could not extract contents of the bundle

jeffschwMSFT commented 5 years ago

@gmeks that error indicates that the process was not able to write to the temp directory. We rely on the OS provided temp location (eg. https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppatha). Can you validate that you have write access to this directory?

gmeks commented 5 years ago

Yea the temp folder is in use and has content ( The program itself also depends on using the temp folder). My general impression is that if GetTempFIle failed the OS would not be usable ( I compile on my workstation)

But more importent, another part of this soltion builds a just fine and works ( Thats a mvc web page, buildt to .exe).

I just verified that i have 71gb free space.

lucas-pollus commented 4 years ago

@gmeks do you still have the problem? I am also going through the same situation and have not found a way out.

gmeks commented 4 years ago

Yes, i still have issues.

My current workaround is to stop publish to standalone binary and use framework depeandant.

onuraltun commented 4 years ago

me too

gmeks commented 4 years ago

Not sure if this is helpfull. But it seems the flaw is in the compile to standalone exe

Im unable to get a working compile to standalone for this project ( I have to compile to framework dependant and install dot .net 3 on the server.

jtsom commented 4 years ago

Well, this is old, with not much updates... I'm seeing this on a Very Simple Dotnet Core 3.1 Razor Pages app, both within Visual Studio using the Publish functionality, and also with the command line tools:

dotnet publish -c Release -r win10-x64 -p:PublishSingleFile=false -p:PublishTrimmed=true

Any further info on this?

sbomer commented 4 years ago

@jtsom are you seeing the same stacktrace that @gmeks shared in https://github.com/dotnet/sdk/issues/3668#issuecomment-534639158? You can check by publishing with -v n.

jtsom commented 4 years ago

@sbomer This is what I get:

       Fatal error in IL Linker
         Unhandled exception. Mono.Cecil.ResolutionException: Failed to resolve Microsoft.WindowsAzure.Storage.Blob.BlobListingDetails
            at Mono.Cecil.Mixin.CheckedResolve(TypeReference self)
            at Mono.Cecil.MetadataBuilder.GetConstantType(TypeReference constant_type, Object constant)
            at Mono.Cecil.MetadataBuilder.AddConstant(IConstantProvider owner, TypeReference type)
            at Mono.Cecil.MetadataBuilder.AddParameter(UInt16 sequence, ParameterDefinition parameter, ParamTable table)
            at Mono.Cecil.MetadataBuilder.AddParameters(MethodDefinition method)
            at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method)
            at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type)
            at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
            at Mono.Cecil.MetadataBuilder.AddTypes()
            at Mono.Cecil.MetadataBuilder.BuildTypes()
            at Mono.Cecil.MetadataBuilder.BuildModule()
            at Mono.Cecil.MetadataBuilder.BuildMetadata()
            at Mono.Cecil.ModuleWriter.<>c.<BuildMetadata>b__2_0(MetadataBuilder builder, MetadataReader _)
            at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
            at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)
            at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
            at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
            at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
            at Mono.Linker.Steps.OutputStep.WriteAssembly(AssemblyDefinition assembly, String directory, WriterParameters writerParameters)
            at Mono.Linker.Steps.OutputStep.OutputAssembly(AssemblyDefinition assembly)
            at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
            at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
            at Mono.Linker.Pipeline.Process(LinkContext context)
            at Mono.Linker.Driver.Run(ILogger customLogger)
            at Mono.Linker.Driver.Execute(String[] args, ILogger customLogger)
            at Mono.Linker.Driver.Main(String[] args)
sbomer commented 4 years ago

Thanks for sharing @jtsom. If you publish without trimming, do you see Microsoft.Azure.Storage.Blob.dll in the output? Your stacktrace points to a cecil limitation, but it is unusual that BlobListingDetails isn't being resolved if your app is using it.

jtsom commented 4 years ago

No, I do not see that in the publish folder.

sbomer commented 4 years ago

@jtsom that is odd. When I create a new webapp and add a packagereference to Microsoft.Azure.Storage.Blob, I get that dll in the output without trimming - and I don't hit the issue that you hit if I do trim. I think we need to understand why that dll is not part of your publish output. Would you be able to share a repro?

jtsom commented 4 years ago

I should be able to get a repo up tomorrow. In the meantime, I'm using the GleamTech DocumentUltimate library, and there is an option to pull from our Azure blob storage. I don't directly add any Azure packages, but possibly the DocumentUltimate package is?

Thanks.

jtsom commented 4 years ago

I've attached the sample project that is showing the errors. The only thing that is not in it is a sample PDF document that is used for testing (it's 100mb). DocViewer.zip

sbomer commented 4 years ago

@jtsom thanks for the repro. I just had some time to look at it (thank you for your patience). It appears that GleamTech has support for multiple storage backends, with references to Azure types that aren't a part of the GleamTech package. It seems they need to be added to the project manually in order to use Azure storage - but the references to these types exist regardless. This causes problems for the linker when it tries to rewrite the assembly with missing references (as described in linked cecil issue).

If you would like to experiment, there is a workaround for this issue. However, the app you shared will likely encounter other problems with trimming since it looks like GleamTech provides custom assembly resolution logic that may not work well with the linker.

For the workaround, you can use the latest SDK with an option to trim the GleamTech assembly, preventing the (unused) reference to the Azure dll from being included in the output assembly. If you would like to try this:

llotall commented 3 weeks ago

Hello, all. I spent toooo much time to resolve this issue. And I want to share solution for you guys.

In my case, i configured Nuget.Config file and specified globalPackagesFolder and repositoryPath configs

example

<configuration>
    <config>
        <add key="repositoryPath" value="C:\SomePath\" />
        <add key="globalPackagesFolder" value="C:\SomePath\" />
    <config />
    <packageSources>
        .... some another resources
        <add key="Local cache" value="C:\SomePath\" />
    <packageSources />

and problem was in reverse backward SLASHES \, MsBuild in some systems don't accept them, to resolve this issue just use SLASH /

I just changed this is NuGet.Config and IT WORKS!

<configuration>
    <config>
        <add key="repositoryPath" value="C:/SomePath/" />
        <add key="globalPackagesFolder" value="C:/SomePath/" />
    <config />
    <packageSources>
        .... some another resources
        <add key="Local cache" value="C:/SomePath/" />
    <packageSources />