rabbitmq / rabbitmq-dotnet-client

RabbitMQ .NET client for .NET Standard 2.0+ and .NET 4.6.2+
https://www.rabbitmq.com/dotnet.html
Other
2.09k stars 584 forks source link

Error with NuGet packing #741

Closed lukebakken closed 4 years ago

lukebakken commented 4 years ago

@keboo @bording - if you have a second to look at this command and the output and provide just a smidge of guidance I would really appreciate it.

We build and publish this library using Debian Buster. Here's how the build image is provisioned, as a Vagrantfile - https://gist.github.com/lukebakken/676bb6d75e30aa5a0bc533f9af87a336

You can see that both dotnet and mono are on the image and I'm wondering if that has something to do with it? I'm going to try reproducing locally with and without mono ... but I think that's still required because net451 is a target.

Note that the shell script is run with -x so that each executed command is prefixed with + in the output. I have attached the full build output to the bottom of this issue.

dotnet pack ./projects/client/RabbitMQ.Client --no-build --configuration SignedRelease --version-suffix pre1

This is the output from that command:

Assembly ./projects/client/RabbitMQ.Client/bin/SignedRelease/net451/RabbitMQ.Client.dll signed.
+ dotnet pack ./projects/client/RabbitMQ.Client --no-build --configuration SignedRelease --version-suffix pre1
Microsoft (R) Build Engine version 16.2.32702+c4012a063 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

/root/.nuget/packages/nuget.build.tasks.pack/4.0.0/buildCrossTargeting/NuGet.Build.Tasks.Pack.targets(104,5): error MSB4018: The "PackTask" task failed unexpectedly. [/tmp/build/b7e18be8/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/RabbitMQ.Client.csproj]
/root/.nuget/packages/nuget.build.tasks.pack/4.0.0/buildCrossTargeting/NuGet.Build.Tasks.Pack.targets(104,5): error MSB4018: System.TypeLoadException: Could not load type 'NuGet.Commands.MSBuildStringUtility' from assembly 'NuGet.Commands, Version=5.2.0.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. [/tmp/build/b7e18be8/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/RabbitMQ.Client.csproj]
/root/.nuget/packages/nuget.build.tasks.pack/4.0.0/buildCrossTargeting/NuGet.Build.Tasks.Pack.targets(104,5): error MSB4018:    at NuGet.Build.Tasks.Pack.PackTask.GetRequest() [/tmp/build/b7e18be8/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/RabbitMQ.Client.csproj]
/root/.nuget/packages/nuget.build.tasks.pack/4.0.0/buildCrossTargeting/NuGet.Build.Tasks.Pack.targets(104,5): error MSB4018:    at NuGet.Build.Tasks.Pack.PackTask.Execute() [/tmp/build/b7e18be8/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/RabbitMQ.Client.csproj]
/root/.nuget/packages/nuget.build.tasks.pack/4.0.0/buildCrossTargeting/NuGet.Build.Tasks.Pack.targets(104,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/tmp/build/b7e18be8/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/RabbitMQ.Client.csproj]
/root/.nuget/packages/nuget.build.tasks.pack/4.0.0/buildCrossTargeting/NuGet.Build.Tasks.Pack.targets(104,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/tmp/build/b7e18be8/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/RabbitMQ.Client.csproj]

This is the entire output: 5.x-pre-release-output.txt

bording commented 4 years ago

This is just a problem with the 5.x branch, right?

You can see that both dotnet and mono are on the image and I'm wondering if that has something to do with it? I'm going to try reproducing locally with and without mono ... but I think that's still required because net451 is a target.

No, with the latest .NET Core SDK and the ReferenceAssemblies package (which I see the 5.x branch has) you no longer need mono installed at all to build. You should be using dotnet commands to build things now.

Microsoft (R) Build Engine version 16.2.32702+c4012a063 for .NET Core

Something seems off there because that is not the latest .NET Core SDK. Using 3.1.100 locally, I'm seeing the following version string:

Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core

Looking the vagrant file:

  apt-get install --yes --fix-missing --no-install-recommends \
    bash \
    debhelper \
    dotnet-sdk-2.2 \
    dotnet-sdk-3.1 \
    elinks \
    elixir \
    erlang-base \
    erlang-nox \
    gettext \
    git \
    libunwind8 \
    libcurl3-gnutls \
    mono-devel \
    msbuild \
    netcat \
    openssh-client \
    openssl \
    python-dev \
    python-simplejson \
    python3 \
    rsync \
    vim \
    wget \
    xmlto \
    xsltproc \
    build-essential \
    zip

You should be able to remove dotnet-sdk-2.2, mono-devel, and msbuild.

bording commented 4 years ago

On another note, now that I'm looking closer at it, the way you're doing the "SignedRelease" stuff is really weird. There's no good reason to be keeping your rabbit.snk private, so you should just be signing things all the time.

Also, you have <DelaySign>true</DelaySign> which means the strong-naming is isn't actually happening. You would need some separate signing step to actually properly sign the thing.

https://docs.microsoft.com/en-us/dotnet/standard/assembly/delay-sign

lukebakken commented 4 years ago

@bording thank you SO MUCH for the assistance. Yes, the delay signing is an issue that was reported recently -

https://groups.google.com/d/topic/rabbitmq-users/FjTPqAslLP0/discussion

I hadn't yet started looking into that due to these other issues. If you can't tell this is the first time I've dealt with the release pipeline for this library 😸

lukebakken commented 4 years ago

This may also be a problem with master, but I haven't tried producing a pre-release there yet. Once I get 5.x fixed I'll make the same changes in master. Again, thanks a lot.

lukebakken commented 4 years ago

This is what I get when running build.sh on a 100% fresh VM without mono-devel, dotnet-sdk-2.2 and msbuild and fresh clone of this project's 5.x branch:

vagrant@DEBIAN-BUSTER-DOTNET:~/rabbitmq-dotnet-client$ ./build.sh
  Restore completed in 33.16 ms for /home/vagrant/rabbitmq-dotnet-client/projects/client/ApigenBootstrap/ApigenBootstrap.csproj.
/home/vagrant/rabbitmq-dotnet-client/projects/client/Apigen/Apigen.csproj : warning NU1701: Package 'System.Xml.XPath.XmlDocument 4.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project. [/home/vagrant/rabbitmq-dotnet-client/RabbitMQDotNetClient.sln]
  Restore completed in 36.86 ms for /home/vagrant/rabbitmq-dotnet-client/projects/client/Apigen/Apigen.csproj.
  Restore completed in 1.81 ms for /home/vagrant/rabbitmq-dotnet-client/projects/client/RabbitMQ.Client/RabbitMQ.Client.csproj.
  Restore completed in 3.45 ms for /home/vagrant/rabbitmq-dotnet-client/projects/client/Unit.WinRT/Unit.WinRT.csproj.
  Restore completed in 1.12 ms for /home/vagrant/rabbitmq-dotnet-client/projects/client/Unit/Unit.csproj.
/home/vagrant/rabbitmq-dotnet-client/projects/client/Apigen/Apigen.csproj : warning NU1701: Package 'System.Xml.XPath.XmlDocument 4.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project.
/home/vagrant/rabbitmq-dotnet-client/projects/client/Apigen/Apigen.csproj : warning NU1701: Package 'System.Xml.XPath.XmlDocument 4.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project.
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.1.0' was not found.
  - The following frameworks were found:
      3.1.2 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:
  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=2.1.0&arch=x64&rid=debian.10-x64

Installing the dotnet-sdk-2.2 package fixes the above issue so I'm assuming it must be required (???). I'll see how this affects signing tomorrow.

bording commented 4 years ago
/home/vagrant/rabbitmq-dotnet-client/projects/client/Apigen/Apigen.csproj : warning NU1701: Package 'System.Xml.XPath.XmlDocument 4.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project. [/home/vagrant/rabbitmq-dotnet-client/RabbitMQDotNetClient.sln]

To fix that warning, you should bump the System.Xml.XPath.XmlDocument package reference to 4.0.1, to match the System.Xml.XmlDocument reference.

It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.1.0' was not found.
  - The following frameworks were found:
      3.1.2 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]

This is happening because we need to run the Apigen project which targets netcoreapp2.1, and it's not finding a 2.x runtime. That could be fixed in a few ways:

So, of those options, for the 5.x branch it's probably easiest to just install the runtime. Instead of using dotnet-sdk-2.2, which brings in all the extra unneeded SDK bits, use dotnet-runtime-2.1 instead. Note that is 2.1. not 2.2. We don't want any 2.2 bits around since that is EOL at this point.

For master, I'd say just change the target framework to netcoreapp3.1.

bording commented 4 years ago

On another side note, I've been wondering about the value of having Apigen at all. The whole premise for it is that the AMQP spec document might change, so we might want to auto-generate new code to respond to it. It doesn't really seem like that's likely to happen again at this point, so you could just rip that out entirely and check in the code it generated.

YulerB commented 4 years ago

+1

lukebakken commented 4 years ago

@bording great thanks for the assistance. I don't see much value in a per-build Apigen either.

michaelklishin commented 4 years ago

We add new protocol methods every so often. It can be extracted into a standalone project if that would simplify things.

On Sun, Mar 1, 2020 at 11:50 PM Luke Bakken notifications@github.com wrote:

@bording https://github.com/bording great thanks for the assistance. I don't see much value in a per-build Apigen either.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rabbitmq/rabbitmq-dotnet-client/issues/741?email_source=notifications&email_token=AAAAIQSUSKR43HKPABKAEJLRFLDDBA5CNFSM4K6B6AAKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENNKP5A#issuecomment-593143796, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAIQQ2M7KBKBFLV7OWOXLRFLDDBANCNFSM4K6B6AAA .

-- MK

Staff Software Engineer, Pivotal/RabbitMQ

stebet commented 4 years ago

I was thinking the same thing last week. As long as the protocol methods are well documented the code could be cleaned up quite a lot and made clearer.

lukebakken commented 4 years ago

Verified as resolved by the recent 5.2.0-pre release.