PowerShellGetv2 icon indicating copy to clipboard operation
PowerShellGetv2 copied to clipboard

Powershell publish-module now failing in 2.1-bionic

Open bo67192 opened this issue 5 years ago • 6 comments

Steps to reproduce the issue

  1. Using a dockerfile like this
FROM mcr.microsoft.com/dotnet/core/sdk:2.1-bionic
RUN dotnet tool install --global PowerShell \
    && apt-get update \
    && apt-get install zip python3 python3-pip -y \
    && pip3 install awscli --upgrade
RUN export PATH="$PATH:/root/.dotnet/tools" \
    && export PATH=~/.local/bin:$PATH \
    && pwsh "Install-Module AWSLambdaPSCore -Confirm:\$false -force; Import-Module AWSLambdaPSCore;"

ENTRYPOINT [ "pwsh" ]

ENV PATH="~/.local/bin:/root/.dotnet/tools:${PATH}"
  1. And a psd1 file like
#
# Module manifest for module 'CommonFunctions'
#
# Generated by: Brian Olson
#
# Generated on: 1/24/2020
#

@{

# Script module or binary module file associated with this manifest.
RootModule = 'CommonFunctions.psm1'

# Version number of this module.
ModuleVersion = '0.0.1'

# Supported PSEditions
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = '76912feb-6ad1-49e9-816c-6d1da3e35976'

# Author of this module
Author = 'Brian Olson'

# Company or vendor of this module
CompanyName = 'Company'

# Copyright statement for this module
Copyright = '(c) 2020 Brian Olson. All rights reserved.'

# Description of the functionality provided by this module
Description = 'Common functions for managing windows machines'

# Minimum version of the Windows PowerShell engine required by this module
# PowerShellVersion = ''

# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = '*'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = '*'

# Variables to export from this module
VariablesToExport = '*'

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = '*'

# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

    PSData = @{

        # Tags applied to this module. These help with module discovery in online galleries.
        # Tags = @()

        # A URL to the license for this module.
        # LicenseUri = ''

        # A URL to the main website for this project.
        # ProjectUri = ''

        # A URL to an icon representing this module.
        # IconUri = ''

        # ReleaseNotes of this module
        # ReleaseNotes = ''

    } # End of PSData hashtable

} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}
  1. Then run
new-item -itemtype Directory -Path /tmp/ -Name "localpsrepo";
Register-PSRepository -Name LocalPSRepo -SourceLocation '/tmp/localpsrepo' -ScriptSourceLocation '/tmp/localpsrepo' -InstallationPolicy Trusted;
publish-module -Name '/<path_to_psd>/CommonFunctions.psd1' -Repository LocalPSRepo -NuGetApiKey 'AnyStringWillDo';

  1. I see
PS /tmp> publish-module -Name '/tmp/ssm/windows-general-config/util/CommonFunctions.psd1' -Repository LocalPSRepo -NuGetApiKey 'AnyStringWillDo';

WARNING: This module '/tmp/275929146/CommonFunctions/CommonFunctions.psd1' has exported functions. As a best practice, include exported functions in the module manifest file(.psd1). You can run Update-ModuleManifest -FunctionsToExport to update the manifest with ExportedFunctions field.
Publish-PSArtifactUtility : Failed to generate the compressed file for module 'dotnet cli failed to pack Microsoft (R) Build Engine version 16.0.450+ga8dc7f1d34 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
  Restore completed in 4.16 sec for /tmp/731842da-0bd1-4f6e-a9c7-02eff13cfe15/Temp.csproj.
  Temp -> /tmp/731842da-0bd1-4f6e-a9c7-02eff13cfe15/bin/Debug/netcoreapp2.0/NotUsed.dll
/usr/share/dotnet/sdk/2.1.607/Sdks/NuGet.Build.Tasks.Pack/build/NuGet.Build.Tasks.Pack.targets(199,5): error : The DateTimeOffset specified cannot be converted into a Zip file timestamp. [/tmp/731842da-0bd1-4f6e-a9c7-02eff13cfe15/Temp.csproj]
/usr/share/dotnet/sdk/2.1.607/Sdks/NuGet.Build.Tasks.Pack/build/NuGet.Build.Tasks.Pack.targets(199,5): error : Parameter name: value [/tmp/731842da-0bd1-4f6e-a9c7-02eff13cfe15/Temp.csproj]
'.
At /root/.dotnet/tools/.store/powershell/6.2.3/powershell/6.2.3/tools/netcoreapp2.1/any/unix/Modules/PowerShellGet/PSModule.psm1:10784 char:17
+ ...             Publish-PSArtifactUtility @PublishPSArtifactUtility_Param ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : FailedToCreateCompressedModule,Publish-PSArtifactUtility
  1. The interesting part looks to be
 The DateTimeOffset specified cannot be converted into a Zip file timestamp. 

Expected behavior

I would expect it to create a valid nuget package file in /tmp/localpsrepo/

Actual behavior

I get the error

Publish-PSArtifactUtility : Failed to generate the compressed file for module 'dotnet cli failed to pack Microsoft (R) Build Engine version 16.0.450+ga8dc7f1d34 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
  Restore completed in 4.16 sec for /tmp/731842da-0bd1-4f6e-a9c7-02eff13cfe15/Temp.csproj.
  Temp -> /tmp/731842da-0bd1-4f6e-a9c7-02eff13cfe15/bin/Debug/netcoreapp2.0/NotUsed.dll
/usr/share/dotnet/sdk/2.1.607/Sdks/NuGet.Build.Tasks.Pack/build/NuGet.Build.Tasks.Pack.targets(199,5): error : The DateTimeOffset specified cannot be converted into a Zip file timestamp. [/tmp/731842da-0bd1-4f6e-a9c7-02eff13cfe15/Temp.csproj]

Additional information (e.g. issue happens only occasionally)

This was working about a week and a half ago, on the same base container.

Output of docker version

PS C:\Users\bolson\Documents\GitHub\dt-tsplus-infra\lambda> docker version
Client: Docker Engine - Community
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        633a0ea
 Built:             Wed Nov 13 07:22:37 2019
 OS/Arch:           windows/amd64
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          19.03.5
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.12
  Git commit:       633a0ea
  Built:            Wed Nov 13 07:29:19 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.10
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
 runc:
  Version:          1.0.0-rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker info

PS C:\Users\bolson\Documents\GitHub\dt-tsplus-infra\lambda> docker info
Client:
 Debug Mode: false
 Plugins:
  app: Docker Application (Docker Inc., v0.8.0)
  buildx: Build with BuildKit (Docker Inc., v0.3.1-tp-docker)

Server:
 Containers: 3
  Running: 0
  Paused: 0
  Stopped: 3
 Images: 14
 Server Version: 19.03.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
 runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.19.76-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 959.3MiB
 Name: docker-desktop
 ID: 3IEB:2FJL:J6WZ:JR3F:OTXQ:GQ6F:L2AO:7ZTO:RTVT:X2SM:VWY2:BUGX
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 34
  Goroutines: 51
  System Time: 2020-01-24T21:46:45.133546244Z
  EventsListeners: 3
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine

I had mentioned this here and @MichaelSimons suggested moving this over here.

He thought it might be related to this Nuget issue

I'm stumped, and I'd really appreciate any help!

bo67192 avatar Jan 27 '20 16:01 bo67192

@bo67192 The cmdlet is not in the repo, it is in PowerShellGet repository. Please move the issue there.

iSazonov avatar Jan 27 '20 17:01 iSazonov

@bo67192 thanks for reporting this issue, you mentioned

This was working about a week and a half ago, on the same base container.

When this was working what version of dotnet were you using?

Thanks! It would also be great to know if you are able to repro this locally, outside of a container?

SydneyhSmith avatar Jan 31 '20 21:01 SydneyhSmith

Looking closer we agree that it seems like the issue you linked may be the same, curious if you have tried any of the workarounds mentioned in that issue?

SydneyhSmith avatar Jan 31 '20 21:01 SydneyhSmith

@SydneyhSmith - I agree the linked NuGet issue mentions some potential workarounds, the thing I noticed was that something publish-module was doing seemed to be resetting the file timestamps. Why is this happening? Is the underlying issue outside of NuGet?

MichaelSimons avatar Jan 31 '20 21:01 MichaelSimons

@SydneyhSmith , I had some issues come up at work that made me move away from this work for a while, the last I know it was working was for a team demo on January 14th.

I'm looking at the workarounds, but I'm not sure how I would run them. I'm not directly running any msbuild commands, so how could I inject

Get-ChildItem -File -Recurse | % {$_.LastWriteTime = (Get-Date)}

into the middle of a publish-module?

Appreciate any help you can provide!

bo67192 avatar Jan 31 '20 22:01 bo67192

Folks, @MichaelSimons @SydneyhSmith @bo67192 did we have progress on this problem? I spent several days hitting the same problem here - https://github.com/PowerShell/PowerShellGet/issues/584

Still, not clear on the path forward.

avishnyakov avatar Feb 14 '20 04:02 avishnyakov