gaelcolas / gaelcolas/Sampler

build.ps doesn't handle unmapped UNC-paths

Open
#494 0 comments 1 reaction 0 assignees View on GitHub
enhancement help wanted
Dominant language
PowerShell
Stars
243
Forks
46
Avg merge
1h 41m
Merged PRs (30d)
1

Description

### 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

```text
-
```

### 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

```text
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

```text
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

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.