gaelcolas / Sampler

Module template with build pipeline and examples, including DSC elements.
MIT License
171 stars 42 forks source link

Build task publish_nupkg_to_gallery should allow publishing with .NET SDK nuget #433

Closed pshamus closed 1 year ago

pshamus commented 1 year ago

Problem description

The build task publish_nupkg_to_gallery explicitly requires nuget.exe. However, certain Docker images like any build on Alpine Linux make it very challenging to install the nuget.exe. As a workaround, the .NET SDK nuget command works perfectly.

Verbose logs

N/A

How to reproduce

Run build.ps1 -Tasks publish on a system without nuget and the log output will show the following:

Task /publish/publish_nupkg_to_gallery skipped.

Expected behavior

Build task publish_nupkg_to_gallery will publish a Nuget package using the .NET SDK in addition to nuget.exe.

Current behavior

Publishing task is skipped.

Suggested solution

On the task publish_nupkg_to_gallery, add a check for the command dotnet and then add logic to the task to conditionally try dotnet first, if found, otherwise fallback to nuget.

Operating system the target node is running

bash-5.1# cat /etc/*-release && cat /proc/version
3.16.3
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.16.3
PRETTY_NAME="Alpine Linux v3.16"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"
Linux version 5.15.49-linuxkit-pr (root@buildkitsandbox) (gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, GNU ld (GNU Binutils) 2.35.2) #1 SMP Thu May 25 07:17:40 UTC 2023

PowerShell version and build the target node is running

PS /> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.7
PSEdition                      Core
GitCommitId                    7.2.7
OS                             Linux 5.15.49-linuxkit-pr #1 SMP Thu May 25 07:17:40 UTC 2023
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module version used

0.116.5