Skip to content
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

Allow automatic variable Is* inside PowerShell module manifest file #9386

Closed
fMichaleczek opened this issue Apr 17, 2019 · 2 comments
Closed
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Resolution-Duplicate The issue is a duplicate.

Comments

@fMichaleczek
Copy link

NugetPackage have sometimes 2 distincts dll for Windows/Unix plateform.
It's not possible to determine which OS is running from a PowerShell module manifest file.
This issue should be resolved in early PS 7.0 cycle because Net.Core 3.0 will add more scenarios with cross plateforms.

Steps to reproduce

Add a condition with variable IsWindows into the property RequiredAssemblies inside a PowerShell module manifest file.

RequiredAssemblies =  @(
    if ( $IsWindows ) { 
        '.\bin\LibName\runtimes\win\lib\netstandard2.0\LibName.dll' 
    }
    else { 
       '.\bin\LibName\runtimes\unix\lib\netstandard2.0\LibName.dll' 
    }
)

Expected behavior

PowerShell module manifest file is loaded.

Actual behavior

PowerShell Error

import-module : The module manifest 'ModuleName.psd1' could not be processed because it is not a valid PowerShell module manifest file. Remove the elements that are not permitted: At ModuleName.psd1:50 char:10
+     if ( $IsWindows ) {
+          ~~~~~~~~~~
A variable that cannot be referenced in restricted language mode or a Data section is being referenced. Variables that can be referenced include the following: $PSCulture, $PSUICulture, $true, $false, $null, $PSScriptRoot, $PSEdition, $EnabledExperimentalFeatures.

Environment data

Name                           Value
----                           -----
PSVersion                      6.2.0
PSEdition                      Core
GitCommitId                    6.2.0
OS                             Microsoft Windows 10.0.17134
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
@fMichaleczek fMichaleczek added the Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a label Apr 17, 2019
@vexx32
Copy link
Collaborator

vexx32 commented Apr 17, 2019

Interesting idea... I hit a similar issue when trying to use SkiaSharp. I ended up solving the issue in a PSM1: https://github.com/vexx32/PSWordCloud/blob/master/Module/PSWordCloud.psm1

@iSazonov
Copy link
Collaborator

iSazonov commented Apr 17, 2019

@fMichaleczek Thanks for your suggestion.
It is dup #5541 Please discuss/vote there to add in 7.0 milestone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Resolution-Duplicate The issue is a duplicate.
Projects
None yet
Development

No branches or pull requests

3 participants