Skip to content

WIP: Add NuGet.Build.Tasks.Pack package #700

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

Closed
wants to merge 1 commit into from

Conversation

lukebakken
Copy link
Collaborator

This should re-enable per-PR releases to MyGet

@lukebakken lukebakken added this to the 6.0.0 milestone Jan 27, 2020
@lukebakken lukebakken self-assigned this Jan 27, 2020
@bording
Copy link
Collaborator

bording commented Jan 28, 2020

What problem are you running into? You should never need to reference this package directly.

@lukebakken
Copy link
Collaborator Author

Without it dotnet pack fails in our Linux CI build infrastructure. The repository with the CI code isn't public but this is the script that is run when a PR is built, for instance:

#!/bin/sh
set -ex

# redirect all output to standard output stream
exec 2>&1

readonly script_dir="$(cd "$(dirname "$0")" && pwd)"
readonly src_dir="$(cd "$script_dir/../../../rabbitmq_dotnet_client" && pwd)"
readonly assembly_info_file="$src_dir/projects/client/RabbitMQ.Client/src/client/properties/AssemblyInfo.cs"
readonly project_file="$src_dir/projects/client/RabbitMQ.Client/RabbitMQ.Client.csproj"

cd "$src_dir"

# make suffix from git sha
readonly suffix="pr-$(git log --pretty=format:'%h' -n 1)"

# perform main build
./build.sh

# build the client using the Release target
dotnet build "$src_dir/projects/client/RabbitMQ.Client" --configuration Release --version-suffix "$suffix"

# pack without re-building
dotnet pack "$src_dir/projects/client/RabbitMQ.Client" --no-build --configuration Release --version-suffix "$suffix"

# push the package to myget
dotnet nuget push -k "$MYGET_API_KEY" -s https://www.myget.org/F/rabbitmq/api/v2/package \
    "$src_dir/projects/client/RabbitMQ.Client/bin/Release/RabbitMQ.Client.*.nupkg"

@lukebakken
Copy link
Collaborator Author

Example failure output:

Time Elapsed 00:00:03.77
+ dotnet build /tmp/build/db7f1294/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client --configuration Release --version-suffix 9a303203
Microsoft (R) Build Engine version 16.2.32702+c4012a063 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 260.38 ms for /tmp/build/db7f1294/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/RabbitMQ.Client.csproj.
  RabbitMQ.Client -> /tmp/build/db7f1294/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/bin/Release/netstandard2.0/RabbitMQ.Client.dll
  RabbitMQ.Client -> /tmp/build/db7f1294/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/bin/Release/net461/RabbitMQ.Client.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.10
+ dotnet pack /tmp/build/db7f1294/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client --no-build --configuration Release --version-suffix 9a303203
Microsoft (R) Build Engine version 16.2.32702+c4012a063 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

/tmp/build/db7f1294/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/RabbitMQ.Client.csproj : error MSB4057: The target "pack" does not exist in the project.

@lukebakken
Copy link
Collaborator Author

Example success output:

+ dotnet build /tmp/build/db7f1294/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client --configuration Release --version-suffix 07650ce2
Microsoft (R) Build Engine version 16.2.32702+c4012a063 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 284.67 ms for /tmp/build/db7f1294/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/RabbitMQ.Client.csproj.
  RabbitMQ.Client -> /tmp/build/db7f1294/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/bin/Release/netstandard2.0/RabbitMQ.Client.dll
  RabbitMQ.Client -> /tmp/build/db7f1294/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/bin/Release/net461/RabbitMQ.Client.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.25
+ dotnet pack /tmp/build/db7f1294/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client --no-build --configuration Release --version-suffix 07650ce2
Microsoft (R) Build Engine version 16.2.32702+c4012a063 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Successfully created package '/tmp/build/db7f1294/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/bin/Release/RabbitMQ.Client.6.0.0-07650ce2.nupkg'.
/root/.nuget/packages/nuget.build.tasks.pack/5.4.0/buildCrossTargeting/NuGet.Build.Tasks.Pack.targets(198,5): error NU5105: The package version '6.0.0-07650ce2' uses SemVer 2.0.0 or components of SemVer 1.0.0 that are not supported on legacy clients. Change the package version to a SemVer 1.0.0 string. If the version contains a release label it must start with a letter. This message can be ignored if the package is not intended for older clients. [/tmp/build/db7f1294/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/RabbitMQ.Client.csproj]
+ dotnet nuget push -k f9cd46b4-3c37-4774-a21e-ac55d00271ca -s https://www.myget.org/F/rabbitmq/api/v2/package /tmp/build/db7f1294/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/bin/Release/RabbitMQ.Client.*.nupkg
info : Pushing RabbitMQ.Client.6.0.0-07650ce2.nupkg to 'https://www.myget.org/F/rabbitmq/api/v2/package'...
info :   PUT https://www.myget.org/F/rabbitmq/api/v2/package/
info :   Created https://www.myget.org/F/rabbitmq/api/v2/package/ 1478ms
info : Your package was pushed.

Strangely enough that version is no longer showing up on myget.org. I could swear it was just there. Anyway, the goal of this process is to make pull request builds publicly accessible via NuGet.

@lukebakken lukebakken marked this pull request as ready for review January 28, 2020 01:37
@lukebakken lukebakken changed the title Add NuGet.Build.Tasks.Pack package WIP: Add NuGet.Build.Tasks.Pack package Jan 28, 2020
@bording
Copy link
Collaborator

bording commented Jan 28, 2020

What version of the .NET Core SDK are those scripts running against? Something else must be going on, because that package is not needed to successfully pack a project.

The latest SDK is SDK 3.1.101, so I suggest installing that first and see if it works.

@lukebakken
Copy link
Collaborator Author

+ dotnet --version
2.2.402

I'll see about updating our CI image. I remember seeing this issue when testing on Windows until I installed the correct SDK version.

@michaelklishin
Copy link
Contributor

I use 3.1 locally.

@lukebakken
Copy link
Collaborator Author

Yep I'm updating the CI image, which should resolve this.

@lukebakken
Copy link
Collaborator Author

@bording unfortunately installing both the 2.2 and 3.1 SDK packages on our debian build image does not resolve the issue. Please see the following output: publish-pr-48-error.txt

This should re-enable per-PR releases to MyGet
@lukebakken lukebakken force-pushed the lrb-restore-nuget-pack-on-pr branch from d4cc824 to 53b1e09 Compare January 28, 2020 23:43
@bording
Copy link
Collaborator

bording commented Jan 28, 2020

I wish there was some way for me to repro the problem locally, because you 100% don't need to reference that package, (and in some cases referencing it could even cause problems/conflicts I think) so there is something else going on.

@lukebakken
Copy link
Collaborator Author

lukebakken commented Jan 28, 2020

@bording I can provide a Vagrantfile that will provision a Debian 10 VM with exactly the same software that our CI image uses. Would that work for you?

Or, if you use Docker, the image we use is available here.

I will modify the script we use to reproduce the problem and will post it here in a response.

@bording
Copy link
Collaborator

bording commented Jan 29, 2020

I think I might have figured out the problem:

https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/master/projects/client/RabbitMQ.Client/RabbitMQ.Client.csproj#L2-L4

You need to get rid of that. That's preventing the SDK's pack task from being used.

michaelklishin added a commit that referenced this pull request Jan 29, 2020
Makes dotnet pack work. Kudos to @bording for figuring it out
in #700.
@michaelklishin
Copy link
Contributor

@bording's advice seems to work, at least without that dummy task dotnet pack succeeds for me.

@lukebakken
Copy link
Collaborator Author

Thanks @bording. I've got some other build errors to address before merging.

@lukebakken lukebakken closed this Jan 29, 2020
@lukebakken lukebakken deleted the lrb-restore-nuget-pack-on-pr branch January 29, 2020 19:00
@lukebakken lukebakken removed this from the 6.0.0 milestone Jan 29, 2020
lukebakken pushed a commit that referenced this pull request Feb 12, 2020
Makes dotnet pack work. Kudos to @bording for figuring it out
in #700.

(cherry picked from commit 9b239f0)
lukebakken pushed a commit that referenced this pull request Feb 13, 2020
Makes dotnet pack work. Kudos to @bording for figuring it out
in #700.

(cherry picked from commit 9b239f0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants