gaelcolas / Sampler

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

build.ps doesn't handle unmapped UNC-paths #494

Open DennisL68 opened 2 months ago

DennisL68 commented 2 months ago

Problem description

When trying to build a module stored on a share using a pure UNC-path (i.e. \server\share\mymodule not mapped to a drive letter), the build fails with the error message

Get-SamplerAbsolutePath : Cannot bind arguments to parameter 'Path' because it is null. At C:\Program Files\WindowsPowerShell\Modules\Sampler\0.118.1\tasks\Clean.ModuleBuilder.build.ps1:17 char:25

Verbose logs

-

How to reproduce

cd \\server\share\mymodule
.\build.ps1 .

Expected behavior

The Sampler should check that the path is not an UNC-path as some cmdlets doesn't work with UNC-paths and output an error referring to UNC-paths not being supported for source files.

Current behavior

The build fails, but it's not apparent it is because of the path being an UNC-path and not a drive letter path.

Suggested solution

I'm assuming that the param RelativeTo is the one that needs to be checked in the function Get-SamplerAbsolutePath.

if (([uri]$RelativeTo).IsUnc) {
  Write-Error 'UNC paths not supported' -ErrorAction Stop
}

Operating system the target node is running

OsName               : Microsoft Windows 10 Enterprise
OsOperatingSystemSKU : EnterpriseEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 19041.1.amd64fre.vb_release.191206-1406
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell version and build the target node is running

Name                           Value
----                           -----
PSVersion                      5.1.19041.4780
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.4780
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Module version used

Name    Version Path
----    ------- ----
Sampler 0.118.1 C:\Program Files\WindowsPowerShell\Modules\Sampler\0.118.1\Sampler.psd1